2014년 3월 25일 화요일

[VS2013]VA 사용시 사용자정의(VA Snippets)이 정상동작하지 않을때의 대처


VA Options -> Advanced -> Listboxes -> Enable Visual Assist completion, suggestion and member listboxes in C#

VA Options -> Advanced -> Suggestions -> Include VA Snippets in listboxes

위의 두 옵션이 켜져 있는지 확인한다.

2014년 3월 19일 수요일

[Unity3D]transform.find, findChild 가 원하는 게임오브젝트를 찾지 못할때


원인은 알수없으나 찾고자 하는 게임오브젝트의 깊이가 너무 깊을때

찾지 못하는 현상이 있다 이를 해결하기 위해선 전체경로를 사용해준다

Transform LeftHandThumb1 = transform.FindChild("Root/Spine/Spine1/Spine2/LeftShoulder/LeftArm/LeftForeArm/LeftHand/LeftHandThumb1");

Transform RightHandThumb1 = transform.Find("Root/Spine/Spine1/Spine2/RightShoulder/RightArm/RightForeArm/RightHand/RightHandThumb1");

2014년 3월 17일 월요일

[Unity3d]Layer변경시 하위까지 변경하는 방법

public static void ChangeLayersRecursively(Transform trans, string name)
    {
        trans.gameObject.layer = LayerMask.NameToLayer(name);
        foreach (Transform child in trans)
        {
            ChangeLayersRecursively(child, name);
        }
    }

[Unity3d]Layer변경할경우 이름으로 변경하는 방법


child.gameObject.layer = LayerMask.NameToLayer("WhateverYouCalledIt");


<http://answers.unity3d.com/questions/168084/change-layer-of-child.html>

[Unity3d]Component를 다른 오브젝트로 복사하고 싶을경우

(http://answers.unity3d.com/questions/458207/copy-a-component-at-runtime.html)
<이함수를 사용하면 된다>



static public T CopyComponent<T>(T original, GameObject destination) where T : Component
    {
        System.Type type = original.GetType();
        Component copy = destination.AddComponent(type);
        System.Reflection.FieldInfo[] fields = type.GetFields();
        foreach (System.Reflection.FieldInfo field in fields)
        {
            field.SetValue(copy, field.GetValue(original));
        }
        return copy as T;
    }