List all objects inside a group


I was looking if this question was asked already but i dint found anything that went this way, or at least that i understood it was.

I have my object, that has a mesh renderer, and inside I have lots of more gameobjects, and some of them may be other groups of objects. How can i list all subobjects and subsubobjects and so on?

I wanted to apply this myObj.renderer.material.color = Color(1f,0f,0f); to every object that has a mesh renderer.


MeshRenderer[] mrs = GetComponentsInChildren();
foreach (MeshRenderer mr in mrs)
	mr.material.color =;