- Home /
Question by
David1901 · Jun 21, 2012 at 12:11 PM ·
javascriptongui
Wiggle Or shake button possible?
i made a button with the onGUI system...
Is it possible to make it shake/wiggle/wave a little when the mouse hovers over it? If yes, how do I do this?
Comment
Answer by IJM · Jun 21, 2012 at 12:17 PM
You can rotate GUI elements, if that's your question. Take a look at this: RotateAroundPivot
But how would i make it shake? Like move one way then the other...to get players attention...
Answer by DaveA · Jun 21, 2012 at 01:57 PM
Each GUI element has a Rect as it's first parameter right? So just modify the x (and/or y) component of that rect. Could be done in OnGUI or Update (modifying the rect that is).
You can use Rect.Contains to see if they are hovering
Rect buttonRect = new Rect (10, 10, 100, 20);
void OnGUI()
{
if (buttonRect.Contains (Event.current.mousePosition)) // the mouse is over the button
// modify buttonRect.x by some delta
if (GUI.Button (buttonRect, .........