- Home /
change child texture problem
Hi, I’m having a little problem. I want to change a texture child from one gameObject but all children with the same name change as well. Any help?
gameObject.transform.Find("Eyes").renderer.material.mainTexture = eyes[2];
Are they all using the same material? http://docs.unity3d.com/Documentation/ScriptReference/Renderer-shared$$anonymous$$aterial.html
yes they are, and i don't know how create a new material for each enemy spawned
Answer by Anusha · Sep 03, 2012 at 01:01 PM
well when u change the texture of a material[thats what ur doing above]..... all the other gameobjects using that material also get effected... so if want to change the texture of a single object make sure the material assigned to it isnt used on any other object.
also use GameObject.FindChild("childname"); if ur searching for the child object...
Answer by t-pedrob · Sep 03, 2012 at 06:08 PM
I can't have a material for each gameObject because i'm spawn them a lot of times.
Any other ideias please?
Your answer
Follow this Question
Related Questions
Changing two different objects renderer colour 1 Answer
How to switch the texture being used by the material of the mesh renderer 1 Answer
How could I make the texture on one object follow the rotation of another object? 0 Answers
Changing texture of childrens 2 Answers
c# - Change a texture so it stays like that when i change scenes 2 Answers