Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

IsPointerOverGameObject returns false if touch position unchanged

Discussion in 'Input System' started by andyasj, Aug 14, 2020.

  1. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    In the editor IsPointerOverGameObject() works fine and returns true when it should, except when the position of the touch is the same next touch, then it returns false!
    If the position of the touch is changed it works fine again.

    Code (CSharp):
    1.  
    2. case TouchPhase.Began:          //new touch 0                                
    3.     joystick.DoActivate(touch0.screenPosition);      
    4.     isOverUI = EventSystem.current.IsPointerOverGameObject(touch0.touchId);  
    5.     Debug.Log(isOverUI);
    6.     break;
    I am simulating the touches using the mouse (if this is relevant) using such as:
    Code (CSharp):
    1.  
    2. InputSystem.QueueStateEvent(touchScreen, new TouchState { phase = TouchPhase.Began, touchId = 1, position Mouse.current.position.ReadValue()});
    3.  
    Difficult to test on android build as it is difficult to get two real touches at the same position.
    Any ideas?
     
  2. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Just having the same problem with mouse, if I toggle Cursor.lockState, the mouse position action does not update till it gets a new event, which is terrible and annoying.

    If anyone has a fix for this, would be cool !
     
  3. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Ping @Rene-Damm , is there a way to force the input system to get the actual value ? Even in the Input debugger it does not display the right value after setting Cursor.lockState = true till we move the mouse