Hello,
I have a GameObject which contains other GameObjects. Is there a functions where returns all the children of a GameObject?
EDIT
Hmmmm this actually works.
var comps = this.GetComponentsInChildren(Transform); for (var comp : Transform in comps) { print(comp.name); }
And if you need the game object, it's just comp.gameObject (I didn't realize this at first).
See this answer - as well as the solution you discovered, it provides a little more information on the subject:
How can I access the children of a transform
you should use the GetComponentsInChildren method to get all components of a specific type in the GameObject and it's children and then iterate to get all of them. in C# you should use typeof operator in the argument of the function.
And if you need the game object, it's just comp.gameObject (I didn't realize this at first).
– yoyo