EventSystem.IsPointerOverGameObject() not working on EnhancedTouch.Touch's events

I’m working on a Floating On Screen Stick and I thought I’d use EnhancedTouch’s touch events to update my stick. I want to check if a finger is not over other UI elements to accept the finger as the active finger to move the stick like so…

private Finger activeFinger;

private void Start()
{
    EnhancedTouch.Touch.onFingerDown += OnFingerDown;
}

private void OnDestroy()
{
    EnhancedTouch.Touch.onFingerDown -= OnFingerDown;
}

private void OnFingerDown(Finger finger)
{
    if (activeFinger == null)
    {
        //Condition is always true even if finger is over UI
        if (!EventSystem.current.IsPointerOverGameObject(finger.index))
        {
            activeFinger = finger;
        }
    }
}

I’ve made other sticks in the past and have checked the old Input system’s touches in Update(), but this time around it always returns false. I tried giving the method Pointer.current.deviceId but that as well also returns false when called from the event(check in update and it works fine). I haven’t looked too deep into it but I think the issue is that the EnhancedTouch.Touch events get called before the current EventSystem updates. It’s also worth mentioning that I’m testing this with the Device Simulator.

1 Like

Is this with 1.1-preview.2? If so, would you mind filing a ticket with the Unity bug reporter? (“Help >> Report a Bug…” in the editor’s main menu)

Is there an update on this? I filed a ticket and got a response saying the team is already aware of this bug but I don’t know what has happened since.

1 Like