Question by
JanZagar · Oct 25, 2015 at 07:04 PM ·
c#errorcolorgetkeydown
error CS0117: `Color' does not contain a definition for `red'
This is my code:
void Update () {
if(Input.GetKeyDown(KeyCode.R))
{
gameObject.GetComponent<Renderer>().material.color = Color.red;
}
}
Then i get this error: Assets/Color.cs(9,84): error CS0117: Color' does not contain a definition for
red'
Can someone help me im new to Unity and im following the unity C# scripting tutorials
Comment
Best Answer
Answer by Statement · Oct 25, 2015 at 07:07 PM
Assets/Color.cs
Your script is named the same thing as a Unity type Color.
Rename your script from Color to ColorScript or something like that.
I changed the name of the script and it didnt work then i delted the script and created a new one with the same code and it still didnt work
Silly me when i copied and pasted my code i didnt change public class name... Now it works thank you so much :)