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.

Simulate touch input will fire twice inside the new input system

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

  1. WheresMommy

    WheresMommy

    Joined:
    Oct 4, 2012
    Posts:
    890
    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

    IsometricBacon

    Joined:
    Sep 28, 2017
    Posts:
    26
    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.