The question is answered, right answer was accepted
give color to an object
Thank you for reading my question, probably a very dumb one, but I'm very new on Unity and can't find anywere this.
So i use Unity 5, and I have created an object, how can I give that object a color?
sorry for the dumbness :)
I use this: GameObject[] list = GameObject.FindGameObjectsWithTag ("list"); foreach (GameObject aux in list) { *** GetComponent().material.color = Color.blue; }
but that does not produce anything, when I run the game, the same original dark gray of the cube appears.
*** in here if i put this ins$$anonymous$$d "GetComponent(aux).material.color = Color.blue;" does not compile.
Answer by gorbit99 · Feb 11, 2016 at 05:21 PM
aux.getComponent().material.color = "putYourColorHere"
Answer by DS4 · Feb 11, 2016 at 06:10 PM
Didn't work. I put this "aux.GetComponent().material.color=Color.blue;" but i get this error "The type arguments for method 'UnityEngine.GameObject.GetComponent()' cannot be inferred from the usage. Try specifying the type arguments explicity".
can't figure it out what is wrong by that message.
Thank you for the help.
first of all, in foreach loop: foreach (gameobject obj in list) obj.GetComponent().material.color = Color.blue;