2D Toolkit Forum
2D Toolkit => Support => Topic started by: Vartib on January 25, 2014, 05:30:38 pm
-
I've noticed that .OnHoverOut is activated when a button is clicked. This is causing problems since I need .OnClick to be called before .OnHoverOut. I don't understand why it's doing this since the button is still being hovered over when someone clicks it; shouldn't .OnHoverOut only be called when someone actually moves their mouse out of the button's collider?
-
I can't change the way it behaviour as it will completely change existing behaviour, but if you need to change the behaviour locally the place to do so is tk2dUIItem.Hover* and tk2dUIManager (search for checkForHovers).
-
That's understandable, you have quite a few users at this point!
In case anyone needs this in the future, I think I got it changed correctly in the tk2dUIManager script under the "checkForHovers" section. I changed this...
if (!isPrimaryTouchFound && !isSecondaryTouchFound && hitUIItem == null && !Input.GetMouseButton(0)) //if raycast for a button has not yet been done
{
hitUIItem = RaycastForUIItem( Input.mousePosition );
}
else if (Input.GetMouseButton(0)) //if mouse button is down clear it
{
hitUIItem = null;
}
...to this...
if (!isPrimaryTouchFound && !isSecondaryTouchFound && hitUIItem == null && !Input.GetMouseButton(0)) //if raycast for a button has not yet been done
{
hitUIItem = RaycastForUIItem( Input.mousePosition );
}
If this isn't right please feel free to correct me. Everything seems to be working though :)
-
That's understandable, you have quite a few users at this point!
In case anyone needs this in the future, I think I got it changed correctly in the tk2dUIManager script under the "checkForHovers" section. I changed this...
if (!isPrimaryTouchFound && !isSecondaryTouchFound && hitUIItem == null && !Input.GetMouseButton(0)) //if raycast for a button has not yet been done
{
hitUIItem = RaycastForUIItem( Input.mousePosition );
}
else if (Input.GetMouseButton(0)) //if mouse button is down clear it
{
hitUIItem = null;
}
...to this...
if (!isPrimaryTouchFound && !isSecondaryTouchFound && hitUIItem == null && !Input.GetMouseButton(0)) //if raycast for a button has not yet been done
{
hitUIItem = RaycastForUIItem( Input.mousePosition );
}
If this isn't right please feel free to correct me. Everything seems to be working though :)
A big thank you for finding this fix!