I want to have a simple button that acts like this: I have a Normal State texture, and a Mouse Over Texture. I want the button to rollover when the mouse is over it.
Is there a way to detect if the mouse is over the button and then change the texture? Is this possible with UnityGUI or the only option would be to create the interface in 3D?
asked Dec 05 '09 at 02:57 PM
You cannot detect directly if the mouse is over a texture, but you can check if it's inside its rectangle. Here's an example:
answered Dec 05 '09 at 11:34 PM
UnityGUI supports mouse rollover by default. There are lots of examples in the docs.
This example will react to rollover and click (from the OnGUI script reference):
To answer the first part of your question, search the script reference for "mouse" and you should find all kinds of functions for getting the mouse state. Then based on whatever state you're in, your script could use thisTexture.enabled = true and thatTexture.enabled = false to switch visibility of 2 different textures on rollover (for example).
answered Dec 05 '09 at 03:34 PM