- Home /
Custom RGBA color value cyan bug
I have some 3D text with box colliders on my main menu that change color when you scroll over them. It works fine, but when I try to use custom RGB values it breaks. Here is my main menu script:
// Custom shade of green, RGBA value: 0, 217, 70, 255 var cGreen = new Color(0, 217, 70, 255);
function OnMouseEnter(){ // Change the color of the text when scrolled over renderer.material.color = Color.blue; }
function OnMouseExit(){ // Change the color of the text back to the original color renderer.material.color = cGreen; }
The problem here is with the OnMouseExit function. For some reason instead of reverting to the original color when the mouse is scrolled away from the text, it turns into a bright cyan color. 0, 217, 70, 255 is the exact RGBA value for the shade of green I want, and I've tried setting cGreen to (0, 0, 0) to test that, and it still turned into bright cyan. Anyone know why this bright cyan color bug is happening? Anyone know a better way of creating a custom RGBA color value and setting my text color equal to it when the mouse is scrolled off of it?
Answer by whydoidoit · Jun 17, 2012 at 10:33 PM
Color uses float parameters not integers! 0...1
If you want to use 0..255 byte values, use Color32(r,g,b,a). This will convert implicitly to/from Color.
Your answer
Follow this Question
Related Questions
Main menu not working 1 Answer
how to make a lock level on a main menu 0 Answers
CS8025 error on play button 1 Answer
Huge difference in memory size from Android to Iphone(IOS) 0 Answers
How to create a page that opens for a few seconds then closes? 0 Answers