How can i get the children of a GameObject and all the children of the children ....
i want to get all the gameobjects under a gameobjects even if they are the children of the children of the children .....
is there a specific method or should i use loop, if loop then how?
Answer by JoshDangIt · May 24, 2016 at 11:06 PM
GetComponentsInChildren<Transform>();
Every gameobject has a transform, so you can get all transforms and reference transform.gameobject.
NOTE: This will also get the transform of the gameobject the component is attached to (The parent gameobject). You'll have to remove it from the array.
Your answer
Follow this Question
Related Questions
Infinite Time inbetween if statements? 2 Answers
Find child coordinates and pass them further? 0 Answers
Make GameObject child of a child 1 Answer
Referencing the Transform of the children of an Instantiated GameObject _PLEASE HELP!!! 1 Answer
C# to set trigger on animator components of all children 3 Answers