get gameobject name in the hierarchy code example
Example 1: unity find game object by name
//tag
foreach(GameObject fooObj in GameObject.FindGameObjectsWithTag("foo"))
{
if(fooObj.name == "bar")
{
//Do Something
}
}
//isim
foreach (var obje in FindObjectsOfType(typeof(GameObject)) as GameObject[])
{
if(obje.name == "obje")
{
//Do something...
}
}
Example 2: what does gameobject.find return
//It returns null/void