- Home /
Question by
Digital-Phantom · Sep 24, 2017 at 05:23 PM ·
script.not-workingreinstall
Script worked before Unity re-install... now doesnt work?
OK.. was running this very simple color change script yesterday that worked fine. However I did an un-install / re-install of Unity earlier today and now the script doesn't work. I'm not getting any errors... its just simply not doing anything. Anybody have any ideas why?
public Color startColor;
public Color mouseOverColor;
bool mouseOver = false;
void OnMouseEnter()
{
mouseOver = true;
GetComponent<Renderer>().material.SetColor("_color", mouseOverColor);
}
void OnMouseExit()
{
mouseOver = false;
GetComponent<Renderer>().material.SetColor("_color", startColor);
}
Any help greatly appreciated, thanks
Comment
Perhaps the scene got changed somehow? Can you confirm the object the script is attached to has an active collider, configured as a trigger?
Best Answer
Answer by Thaun_ · Sep 24, 2017 at 05:41 PM
Ive tested your code, and the problem is that its "_Color" not "_color". I hope this helps.
Copy Pasta Code:
public Color startColor;
public Color mouseOverColor;
bool mouseOver = false;
void OnMouseEnter()
{
mouseOver = true;
GetComponent<Renderer>().material.SetColor("_Color", mouseOverColor);
}
void OnMouseExit()
{
mouseOver = false;
GetComponent<Renderer>().material.SetColor("_Color", startColor);
}