0
\$\begingroup\$

I want to detect when a UI object it dragged and released on top of a game object. The drags starts on a sprite on the canvas outside of the game object. I tried using OnMouseUp() but it only work if the MouseDown event happens on the same game object. How can I detect MouseUp events that started outside of my object and ended inside the object.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I solved this problem by checking if the mouse is currently over the game object and checking if the mouse button is released inside the function

 void OnMouseOver()
    {
        Debug.Log("OnMouseOver on GameObject");
        if (Input.GetMouseButtonUp(0))
        {
            Debug.Log("MouseButtonUp");
        }
    }
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .