Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Simulate touch input will fire twice inside the new input system

Discussion in 'Input System' started by WheresMommy, Dec 4, 2020.

  1. WheresMommy


    Oct 4, 2012
    I just want everyone to know, that using the simulate touch function in the input debugger can cause your UI Button OnClick events to get fired twice.

    Just was fiddeling around with this for some hours until I found out this was the issue.
  2. IsometricBacon


    Sep 28, 2017
    Can confirm this happens to me too.

    My best guess is this is because it's both firing a touch event and a mouse click event at once. So it's both touching the button and clicking the button, resulting in a double event fire.

    I'm thinking this, because that is also what seems to happen when you both capture 'mouse' button clicks and 'touches' separately with InputAction Maps. Doing a touchscreen press will capture both a undesired click and the touchscreen touch, and not treat them as seperate objects.

    Since our application uses both touchscreen and mouse for navigation (but in different ways) this has proven to be really problematic. I've had to differentiate mouse input handling from touchscreen input handling by ensuring that there's no fingers on the touchscreen before handling input. Messy.

    Our project includes a bunch of code to disable / enable the TouchSimulation component at runtime. (since our devs don't always have access to a touchscreen), but this bug means that we can't use any general 'onclick' button events without having to wrap every function call with a bad fix like above.