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
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.
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;