Unity Znajdź gameObject po imieniu
GameObject enemy = GameObject.Find("enemy");
RasKaL
GameObject enemy = GameObject.Find("enemy");
GameObject FindChildRecursive(GameObject parent, string childName) {
foreach(Transform child in parent.transform) {
if(child.name == childName) {
return child.gameObject;
} else {
if(child.childCount > 0) {
GameObject result = FindChildRecursive(child.gameObject, childName);
if(result != null) return result;
}
}
}
return null;
}
public GameObject obj;
void Start()
{
string objName = obj.name;
Debug.Log(objName);
}