I'm trying to make some arrows in order to show the parts of my 3d object. When I press the button to enable and show my arrows they become visible in white.
But I want to change the color to red when my mouse is over of certain button.
Now I can enabled and vanish my arrows and change the color to red from white, when the mouse cursor is over the button or Rect area assigned to change the color.
But when the cursor is outside of the Rect assigned to change the color. The color white is not back again.
Any advice is more than welcome!
Please take a look to this little short video.
Please take a look to my Script.
asked Feb 12 '13 at 09:05 PM
the easiest way would be add an else to your mousePosition if statement
answered Feb 12 '13 at 09:19 PM
Looks like you never set the color back to white once your mouse leaves the rect. Also, you are constantly setting the color every frame while the mouse is inside the rect.
Maybe try putting a bool to test whether it's on or not. Then, add a function that will change the color based on the parameter you pass to it.
Try this, at the top of your class, add a private variable:
then in your update function, change your mouse over check to this:
Then add a new method that will change the color based on whatever you pass to it:
FYI, there are a few GUI packages that might make it easier to handle the UI. EZGUI is one, and we've also tried UIToolKit from Prime31. It's free and open-source--not the ideal solution but I thought it worked well.
P.S. I apologize if my JS syntax is incorrect, I primarily use C#.