Get Child With Name Unity Code Example


Example 1: find child of gameobject unity


gameObject.transform.Find("ChildGameObject").gameObject;

//This insures that you are finding the child instead of finding another
//GameObject's Child.

Example 2: unity get child


GameObject Child;
Child = transform.GetChild(0).gameObject;

Example 3: unity how to get a child from a gameobject


//For unity engine
GameObject.transform.GetChild(The child index).transform;

Example 4: unity get child gameobject


//Instantiate Prefab
GameObject originalGameObject = Instantiate(prefab);

//To find `child1` which is the first index(0)
GameObject child2 = originalGameObject.transform.GetChild(0).gameObject;

//To find `child2` which is the second index(1)
GameObject child2 = originalGameObject.transform.GetChild(1).gameObject;

//To find `child3` which is the third index(2)
GameObject child3 = originalGameObject.transform.GetChild(2).gameObject;

Example 5: get gameobject child by name


Gameobject.Find("ChildName") ;

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable