2016. 2. 25. 11:38

함수 

Component GetComponentInChildren<type>() 

설명

게임오브젝트에서 type 타입의 컴포넌트나 depth-frist 찾기를 해서 얻은 그것의 자녀들 중 가장 빠른 자식을 돌려준다.


오직 활성 컴포넌트만 검사한다. 


1
2
3
4
5
6
7
8
9
10
using UnityEngine;
using System.Collections;
 
public class example : MonoBehaviour {
    public ScriptName mScript;
    void Start() {
        mScript = gameObject.GetComponentInChildren<ScriptName>();
        mScript.DoSomething();
    }
}
cs


Posted by 시리시안