- Home /
Emissive color is not changing
When I hover over item it changes color, the problem is the Emissive part is not changing. All my items change to red when hovering over, but my red item needs to be different color like yellow, it changes yellow but the emissive part is not changing. The hover color mixes to an orange color which is very hard to see. The item is an Transparent/vertexLit, it contains Main, specular, and Emisive color.
void OnMouseEnter() {
redColor = new Color32(255,0,0,255);
startcolor = renderer.material.color;
GameObject.Find("Main Camera").GetComponent<Location>().color = startcolor;
if (startcolor == redColor){
renderer.material.color = Color.yellow;
renderer.material.SetColor("_Emission", Color.yellow);
}
else renderer.material.color = Color.red;
renderer.material.SetColor("_Emission", Color.red);
}
Comment
Best Answer
Answer by HarshadK · May 28, 2014 at 12:27 PM
You missed bracket for else loop.
void OnMouseEnter() {
redColor = new Color32(255,0,0,255);
startcolor = renderer.material.color;
GameObject.Find("Main Camera").GetComponent<Location>().color = startcolor;
if (startcolor == redColor){
renderer.material.color = Color.yellow;
renderer.material.SetColor("_Emission", Color.yellow);
}
else {
renderer.material.color = Color.red;
renderer.material.SetColor("_Emission", Color.red);
}
}
Oh my goodness, that was the last thing I was looking at. Thx a bunch. It was correct at first, but then I decided to at an extra line for the emissive color.
Your answer