I have code for dragging an object that checks to make sure the mouse is within the screen rect. If you’re dragging and you move the mouse outside the Unity Player frame, it stops dragging. This works as expected in Unity, but not in the browser. If you drag outside the Unity frame then release the mouse, the player does not recognize the next mouse click. So if I start dragging something and my mouse moves outside, the drag stops. When I move the mouse back and click to continue the drag, I have to click twice before it will drag again.
It seems like Unity doesn’t know the mouse was released when it’s in another part of the window. So the next click, it thinks the mouse was still down from before. Or so it would seem. Is there any way to avoid this, or to make sure Unity knows when the mouse is released?
When clicking outside the Unity frame in the browser your effectively de-focusing the content, this is how we handle focus in the browser. 1 click inside the Unity frame to gain focus and 1 click outside the frame to de-focus. So when your dragging outside the frame you must be losing focus to the player hence no input recognition.
It’s worth checking this script reference to workaround the problem: