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.
\$\begingroup\$
\$\endgroup\$
Add a comment
|
1 Answer
\$\begingroup\$
\$\endgroup\$
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");
}
}