- Home /
Change shader color for specific GameObject
Is it possible to change the color (property) of a shader for a specific game object without changing the color of the other game objects which share the same shader? How?
Answer by Aydan · Oct 21, 2011 at 12:27 PM
Yes it's possible use a script like this:
var target : GameObject;
function Update(){
if(Input.GetButtonDown("Jump"))
target.transform.renderer.material.color = Color.green;
}
this just changes the color of the target object when you press spacebar. Is this what you were looking for?
but i am getting error:here is no 'Renderer' attached to the "monster(Clone)" game object, but a script is trying to access it. You probably need to add a Renderer to the game object "monster(Clone)". Or your script needs to check if the component is attached before using it.
Your answer
Follow this Question
Related Questions
Creating a line between different colors? 0 Answers
How to get the real color of the vertices in a mesh modified by a shader? [C#] 0 Answers
Material doesn't have a color property '_Color' 4 Answers
Shader Graph Edit Parameters From Script 4 Answers
How to swap out RGB colors of a sprite using ShaderGraph? (Like in Among Us) 3 Answers