2016. 2. 25. 11:49

함수 

Component GetComponent<type Stirng>

설명

만약 게임 오브젝트에 type에 맞는 컴포넌트가 있다면 그 컴포넌트를 찾아서 돌려주고,, 없으면 null 를 돌려준다


 

1
2
3
4
5
6
7
8
9
10
using UnityEngine;
using System.Collections;
 
public class mGetcomponentExample: MonoBehaviour {
    void Start() {
        Transform mTransform;
        mTransform = gameObject.GetComponent<Transform>();
        mTransform = gameObject.transform;
    }
}
cs


Posted by 시리시안