if(Input.GetKeyDown(KeyCode.R))
{
gameObject.renderer.material.color = Color.red;
}
Error: ‘Color’ does not contain a definition for ‘red’
What have i done wrong?
if(Input.GetKeyDown(KeyCode.R))
{
gameObject.renderer.material.color = Color.red;
}
Error: ‘Color’ does not contain a definition for ‘red’
What have i done wrong?
Color red = new Color(255,0,0);
if(Input.GetKeyDown(KeyCode.R)) {
gameObject.renderer.material.color = red;
}
Does this work for you?
What you did was name your class the same thing as a Unity class (that is, “Color”), which obscures UnityEngine.Color. Either distinguish them like that or better yet use a different name.