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.