1
\$\begingroup\$

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 OnPointerUp 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?

\$\endgroup\$
1

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.