Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UI via Xbox controller get double inputs in UWP

Discussion in 'Windows' started by pumpkinszwan, Jan 29, 2017.

  1. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    When I press a UI button via the Xbox controller in my UWP builds, it often acts like I've pressed multiple times. This happens in UWP builds, but not standalone builds, nor in the editor.

    For example, I will select the Play button from my main menu and press 'A' on the controller. The game will navigate to the next screen, but it will interpret another press of 'A' and choose the first option on that screen (which happens to be the option to return to the main menu).

    I have tried using a single EventSystem that persists through all scenes, and I have tried using a different EventSystem in each scene with UI, and I get the same behaviour regardless.

    I set the 'First Selected' object for each scene as without doing so my game will not recognise controller input until some other input has given the EventSystem focus (e.g. the mouse).

    I've tried adjusting the Repeat Delay to 1 second, which changes nothing.

    Is there something I'm doing wrong in my approach?

    I'm using Unity 5.5.0f3 and the latest retail build of Windows 10.

    I've made a small repro project. In this project if you run in the editor it works as you'd expect. But build and run a UWP version and the button press will repeat and send you back and forth between the two scenes:

    https://drive.google.com/file/d/0BzSVcfbrSparRWZXNUx0Q0NyTkE/view?usp=sharing
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    Sounds like a bug. Could you submit a bug report?
     
  3. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    Thanks. I've submitted a bug report.

    In the meantime is there anything you could suggest to work around this? I am giving out beta copies, and players can't navigate the menus properly.

    Is there a way to make UI input only happen on button release rather than when the button is down? I suppose I could try disabling the EventSystem for a small amount of time at the start of every scene, so if the player has just tapped to navigate there it will ignore input long enough for the player to have released the button.
     
  4. ReactDev

    ReactDev

    Joined:
    Sep 25, 2014
    Posts:
    141
    @pumpkinszwan - did you ever come up with a reasonable workaround for this? We're still seeing this behavior in Unity 5.5.2f1 for UWP builds.
     
  5. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    @ReactDev I did come up with a workaround. It's not particularly elegant, but it works.

    I basically implemented my own input delay. In any method that handles a UI button press I check that it has been at least 0.5 seconds since a button press was last handled. I keep track of the time of the last press in a globally available variable.

    pseudo code:
    void UiButtonPress()
    {
    if(Time.time - timeOfLastButtonPress >= 0.5f)
    {
    HandleButtonClick();
    timeOfLastButtonPress = Time.time;
    }

    }
     
  6. ReactDev

    ReactDev

    Joined:
    Sep 25, 2014
    Posts:
    141
    @Aurimas-Cernius - is there a fix for this planned? Our input system is not in a good place for hacking in something to get around a Unity Windows 10 bug.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    @pumpkinszwan do you happen to have the case # for the issue? I don't think it landed to our issue grabbag (or perhaps I missed it).

    @ReactDev if you have another solid repro, please submit a bug report yourself too (and tell us the case #!). This sounds like a serious issue that we'd want to fix.
     
  8. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Hey I just fixed this yesterday. Basically what happens is that our "button down state" is reset on scene load, and once the scene loads, it thinks the button was pressed during the first frame, while it was actually held down. I'll get this into a patch release soon.
     
    ReactDev and pumpkinszwan like this.
  11. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    Awesome, thanks!