Enabling Multiple MeshRenderer at one time

Hello All!

I have a GameObject that contains multiple GameObjects. Each of the GameObjects inside the main have a MeshRenderer component. I am looking for a way to enable ALL the GameObject MeshRenderers within the Main GameObject.

An Example would be:

MainGameObjectName = GUIImages
InsideMainGameObject = GUIImage1 with MeshRenderer
InsideMainGameObject = GUIImage2 with MeshRenderer
InsideMainGameObject = GUIImage3 with MeshRenderer

And this needs to work in C#


Assuming you want to disable the renderers instead of the gameobjects themselves:

foreach(MeshRenderer renderer in GetComponentsInChildren<MeshRenderer>())
    renderer.enabled = true;