- Home /
Question by
PuneetK · Sep 24, 2013 at 11:27 AM ·
guistylehoverguistylestate
GUIStyle component to be changed during script?
So I want to do some action when the GUI element is hovered on, like make it bigger when you hover over it.
Can someone explain how?
if (GUI.Button (Rect (pauseX + Screen.width * 0.84,pauseY + Screen.height * 0.005, Screen.width * 0.15, Screen.height * 0.09),"",designhome))
{
Application.LoadLevel (0);
Time.timeScale = 1;
print("home button clicked");
}
The textures for this button have been defined in the style. So I need a way to make the button rect bigger, on hovering over it. Please tell me how :)
Comment
Best Answer
Answer by Jamora · Sep 24, 2013 at 12:39 PM
The only way I can think of to do this is by checking if the mouse cursor is contained in the Rect:
if(buttonrect.contains(event.current.mousePosition))
buttonRect = bigButtonRect;
else
buttonRect = smallButtonRect;
GUI.Button(buttonRect, ...);
Thought I could use iTween or something to scale, but guess I'll just be required to make the images themselves bigger or smaller
Your answer
