- Home /
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#
Thanks!
Answer by Mike 3 · Jun 26, 2010 at 09:18 PM
Assuming you want to disable the renderers instead of the gameobjects themselves:
foreach(MeshRenderer renderer in GetComponentsInChildren<MeshRenderer>())
{
renderer.enabled = true;
}
$$anonymous$$ike: You are correct, I only want to enable the $$anonymous$$eshRenderer. Using your code above, how to I tell what GameObject I want to look into? Such as the "$$anonymous$$ainGameObjectName"?
you could just do if(renderer.name == "Your Objects Name") renderer.enabled = true;
Your answer
Follow this Question
Related Questions
I cant turn off mesh renderer on collision! How i can make? 1 Answer
Error when changing materials in the editor on a procedurally generated mesh 0 Answers
What's the difference between .renderer and MeshRenderer? 1 Answer
Why does adding cloth component to skinned meshrenderer move the bounds away from the mesh? 2 Answers
How can I make the shading on my mesh look like the primitives? 2 Answers