Say I have a gui slider controlling a model property and when the user mouse over this slider I want to hilite the 3d model that will be affected by this slider.
Problem is I can't find a way to register a function to gui mouse events. I do not need to modify the style or skin of the gui on mouseover, I need to call a function of mine.
Is it possible? or am I missing the plain obvious?
thanks for your help
Found the answer here:
There is also a clear example on detecting mouseover. Works perfectly.
Here’s a solution that works for GUILayout also … what a hassle.
Just after GUILayout.HorizontalSlider …
if (Event.current.type == EventType.Repaint &&
then in your update routine …
if ( Input.touchCount == 0 ) usingSlider = false;
if ( usingSlider == true ) return;
.. continue as normal...
that’s it !
Check out the answer to this question: Mouseover-Detection.
Anybody knows how to do this in the 4.6 UI ? I don’t want my controls to fire if I’m hovering over my hud elements with the mouse.
@Jean-Fabre 's answer is on point, that is, if your tool uses only one window instance.
Should it allow for more than one instance at a time, the detection breaks a bit.
The only solution I’ve found is to limit the detection to mouse event, and so I replaced Repaint with MouseMove
if (Event.current.type == EventType.MouseMove &&
Don’t forget to add this at the start of OnGUI!
wantsMouseMove = true;