Search Unity

Unity UI EventSystem.current.IsPointerOverGameObject false when clicking on inactive window

Discussion in 'UGUI & TextMesh Pro' started by youmyalis, Mar 2, 2019.

  1. youmyalis

    youmyalis

    Joined:
    Apr 29, 2014
    Posts:
    1
    Hello.

    I have OnMouseDown + OnMouseUp selection of objects in my scene implemented and the clicks are set to not select the objects if they are over an UI element.

    This works well using EventSystem.current.IsPointerOverGameObject() check while working with the application. But it seemingly no longer works once I alt + tab to other window and return to my Unity application by clicking on it. The mouse click on an inactive Unity application window causes the click to pass through the UI layer. Only the first click fails to notice the UI, any follow-up click works properly again.

    The behavior is the same when Run In Background option in Player Settings is either false or true.

    Did anyone else run into this problem and is there any fix/workaround for it? Temporary workaround I use right now is actual disabling of interaction with scene objects when OnApplicationFocus(false) is called and re-enabling it at the end of next Update() after OnApplicationFocus(true), but this seems to me like quite rough solution.

    Note that I actually work with Unity 2017.3.0f3, so if there's a fix in any later version it might be a simple answer to my question as well...