How can I find all the GameObjects a GameObject has?


I have a GameObject which contains other GameObjects. Is there a functions where returns all the children of a GameObject?


Hmmmm this actually works.

var comps = this.GetComponentsInChildren(Transform);

for (var  comp : Transform in comps) {

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.