콤퓨타/Unity
유니티 AddComponent를 사용하여 오브젝트에 스크립트 붙이기
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 오브젝트를 찾은 후 AddComponent를 사용하여 스크립트를 붙여준다.
2023. 8. 28. 09:36