Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question IsPointerOverGameObject with Touchscreen return always false (New Input System)

Discussion in 'Input System' started by MarcAubryBoissel, Apr 21, 2021.

  1. MarcAubryBoissel

    MarcAubryBoissel

    Joined:
    Dec 1, 2016
    Posts:
    8
    Hi, i want to prevent inputs when the user clicking through UI element. Usually I used IsPointerOverGameObject. It works fine in the editor with the mouse. If I click on UI I get true, otherwise I get false.
    But when compiled on Android, the returned value is always false.

    Buttons inputs :
    upload_2021-4-21_16-52-32.png

    I use the default settings :
    upload_2021-4-21_15-59-23.png

    And the default InputSystemUI :
    upload_2021-4-21_15-56-8.png

    Code used for testing :
    Code (CSharp):
    1.     private TouchControls _touchControls = null;
    2.  
    3.     private void Awake()
    4.     {
    5.         _touchControls = new TouchControls();
    6.     }
    7.     private void OnEnable()
    8.     {
    9.         _touchControls.Enable();
    10.     }
    11.     private void Start()
    12.     {
    13.         _touchControls.Test.Tap.started += context => OnTap(context);
    14.     }
    15.     private void OnDisable()
    16.     {
    17.         _touchControls.Disable();
    18.     }
    19.  
    20.     private void OnTap(InputAction.CallbackContext context)
    21.     {
    22.         Debug.Log(EventSystem.current.IsPointerOverGameObject(-1));
    23.         Debug.Log(Touchscreen.current.deviceId.ToString());
    24.         Debug.Log(EventSystem.current.IsPointerOverGameObject(Touchscreen.current.deviceId));
    25.     }
     

    Attached Files:

    Last edited: Apr 21, 2021
    NEW_00_0NE likes this.