- Home /
3D Text Object does not change to the color specified on Mouse Over
Hello. I am currently working on a menu using 3D text, and I have a script on the object that changes the color of the text from yellow to red when I mouse over the object:
function OnMouseOver ()
{
renderer.material.color = Color.red;
}
Unfortunately, for whatever reason I seem to be able to get only 3 different colors for the mouse over: red, green, and black. Whether it's by entering the name of the color, or by grabbing the RGB values. Example: (150,100,25,255)
Is there something in the inspector I need to be setting differently to get the full range of colors available?
Thank you.
I'm not sure where the disconnect is. How the color is handled (or if it is handled at all) is up to the shader. $$anonymous$$any shaders use the color you provide as an overlay color on the object, so the color you get is actually a combination of the color you specify and the color of the object.
One issue with your question is your use of:
Example: (150,100,25,255)
The Color class in Unity uses values in the range of 0 to 1 for all components, so you would not be setting values that you specify. So you would specify a specific color in code like:
var color = Color(0.6, 0.4, 0.1, 1.0);
There is a Color32 class in Unity that handles colors components in the range of 0 - 255, but renderer.material.color does not use it.
Thank you, I think I have a much better understanding of how that system works now. I'm still having trouble getting Yellow text to change to White, but this is a good place to start.