Unity 3D Знайти

2075 / Unity / Unity 3D / Знайти

 

GameObject.Find("Player") – знайти по імені
GameObject.FindGameObjectsWithTag("Monster") – повертає масив об'єктів за тегом
GameObject.FindWithTag("Finish") – повертає один об'єкт

 

Знайти в Canvas

public GameObject obj;

Text t1 = obj.GetComponent<Text>();
t1.text = "OK";

 

Якщо префаби в Resources

Instantiate(Resources.Load("YourBulletPrefab"));

GameObject go = Instantiate(Resources.Load("folder/YourBulletPrefab") as GameObject);