Hey Aren! So this is something that's been bothering me about NGUI for years now. If you are hovering over an object and then left click, and then drag the mouse off of the collider before releasing the mouse, it will never register with that object that it is no longer being hovered over. I believe that after the event of the mouse releasing, NGUI should natively be checking to see what it is now hovering over. This seems more intuitive than the current way it is handled.
Several use case examples are provided below. The steps in bold are what I would not expect NGUI to do.
Case 1Works as expected:
- User hovers over collider.
- OnHover(true) is ran.
- User moves mouse outside of collider.
- OnHover(false) is ran.
Case 2Does NOT work as expected:
- User hovers over collider.
- OnHover(true) is ran
- User clicks and releases immediately over collider
- OnHover(true) is ran again.
- OnHover(false) is never ran.
Expected:
- User hovers over collider.
- OnHover(true) is ran
- User clicks and releases immediately over collider
- OnHover(true) is not ran again.
- OnHover(false) is not ran.
Case 3Does NOT work as expected:
- User hovers over collider.
- OnHover(true) is ran
- User clicks, but does not release yet.
- User drags the mouse off the collider
- User releases the mouse outside of the collider
- OnHover(false) is never ran.
Expected Results:
- User hovers over collider.
- OnHover(true) is ran
- User clicks, but does not release yet.
- User drags the mouse off the collider
- OnHover(false) is ran.
- User releases the mouse outside of the collider
I am able to fix this issue by using the following code in the object that is having the problem:
private void OnDrag()
{
if ( UICamera.hoveredObject != MyGameObject)
OnHover (false);
}
But this seems rather unintuitive to need to deal with OnDrag when I don't want it to have dragging functionality.
What are your thoughts on this?