유니티 AddComponent를 사용하여 오브젝트에 스크립트 붙이기

 




1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class MyExam : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        // GameObject ob = new GameObject("TestAddCom");
 
        GameObject ob = GameObject.Find("TestAddCom");
        TestAddCom addCom = ob.AddComponent<TestAddCom>();
    }
 
   
}
 
cs

TestAddCom 오브젝트를 찾은 후 AddComponent를 사용하여 스크립트를 붙여준다.






댓글

이 블로그의 인기 게시물

유니티 오브젝트 서서히 사라지게

WebView에서 YOUTUBE 동영상 플레이 방법