- Home /
Duplicate Question
Most direct way to create OnCursorStay "event" in UI.
Is there a proper way to perform manual raycasts against UI elements?
Currently I'm implementing...
IPointerEnterHandler, IPointerExitHandler
...and calling an OnEnter / OnExit method which helps track which UI Button element the user is highlighting with their cursor. (To achieve tooltip behavior, more or less.)
This seems to be rather failure-prone: I can easily perform mouse activities that fail to invoke the pointers events; most critically, the exit event. (My tooltips linger.) Losing application focus also seems to create a failed invocation.
This is very undesirable for me, so I'm seeking the most secure, stable way to create the equivalent of an OnStay behavior. I haven't had this specific desire before, so I'm a little lost.
Thanks!
Have you tried the built-in solution?
Tried it just to be certain. No dice. Thanks for your suggestion, though. These are UI elements belonging to a canvas; the doc says On$$anonymous$$ouseOver is for GUIElements or colliders.
I'll have a closer look at the UI docs to see what I can see about a roundabout solution, but I was hoping to learn the best way to handle this situation.
Answer by AlwaysSunny · Apr 16, 2015 at 02:51 AM
This wound up being what I needed. Apologies for the waste of time. :)
http://answers.unity3d.com/questions/821590/unity-46-how-to-raycast-against-ugui-objects-from.html
Follow this Question
Related Questions
How to get UI element into HMD Unity 5.3.4p1 - Oculus Utilities 1.3 0 Answers
Create UI raycast like a mouse Click 2 Answers
Raycast a World Space UI with VR (Daydream) 1 Answer
How do I have clickable buttons in a scroll rect? 1 Answer
Is it possible to configure raycast to hit opaque pixels without using alphaHitTestMinimumThreshold? 1 Answer