I am making a unity mobile game, I have a simple scene and a canvas with a few buttons and these buttons have scripts that detect if the button was pressed and released. Here is the code for doing this:
public class InteractiveButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public void OnPointerDown(PointerEventData eventData)
{
//do something
}
public void OnPointerUp(PointerEventData eventData)
{
//do something
}
}
}
This works perfectly fine as when i press the button the down event gets triggered as expected, but if i keep my finger pressed and drag my fingers off the bounds of the button and let go the pointerUpOnPointerUp method still gets called as if I let my finger go on the button.
So how can I detect if the player lets go out of the buttons bounds?