- Home /
Change only players color but not texture
My game has two players with a same material. But I want OnGUI()
function script that shows buttons with different color names, so when player clicks on a button with the color he wants, then only the color will change.
Felipe
Can you post some code?, and, how many materials have the object?, because there's a way to manipulate the material color.
both of the players have same material, the player is actualy a capsule and what script to do you need?
Answer by hathol · May 29, 2012 at 04:02 PM
If you use a regular diffuse shader, that one comes with a color property. Just make sure every player has a separate instance of the material attached, otherwise the color change will affect both players. You could probably just clone your material and change the color for the new one like so:
Material myMaterial = new Material(renderer.material);
myMaterial.color = Color.red;
renderer.material = myMaterial;
Your answer
Follow this Question
Related Questions
Player object carried from scene to scene 1 Answer
gui.label color change 1 Answer
changing the color of particles using the legacy particle animator? 2 Answers
Blend into next color instead of jumping to next color 1 Answer
How would I change the colour of a prefab relative to the size of the character? 1 Answer