Search Unity

Feedback UI Focus Retention

Discussion in 'Input System' started by Wolftousen, Jan 23, 2020.

  1. Wolftousen

    Wolftousen

    Joined:
    Nov 25, 2016
    Posts:
    10
    Not sure if this should go here or somewhere else, but seems to be more of an input related issue.

    I've noticed that when going back and forth between keyboard/mouse and gamepad in my menu, if i accidentally click on the background or something that doesn't retain focus, the currently focused element loses focus and the gamepad can no longer navigate.

    I know there are a lot of work arounds out there, but it would be nice to have a checkbox in the EventSettings, Input System UI Input Module or EventSystem(Single or Multi) that lets you lock focus to the UI that you can turn on and off via script rather than have to do some work around.
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Yup, this has come up a couple times. A change is in the pipe and is slated for 1.0.0-preview.5 (or whatever the exact version of that will be), i.e. the package after the next one.
     
  3. whitexroft

    whitexroft

    Joined:
    Oct 22, 2012
    Posts:
    48
    Is there a workaround before that happens? Like manually refreshing the system in OnApplicationFocus?
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Unfortunately, ATM I think the only workaround is to manually comment out the eventSystem.SetSelectedGameObject(null,eventData) code in InputSystemUIInputModule.cs within the package cache in Library. Not great.

    Other than that, it's probably down to writing some code that remembers the last selected object and if the system sets it to null, restores the last selection.
     
  5. whitexroft

    whitexroft

    Joined:
    Oct 22, 2012
    Posts:
    48
    Hm, it seems that I am confused about the issue then. I considered it to be the same.
    My issue is that after alt-tabbing (no mouse clicking) and getting back to the build (works fine in editor), gamepad does not navigate. Keyboard does though. Current selected object presents, therefore keyboard has no issues to do it. Gamepad.current presents, it all seems to be fine, however UI does not react to gamepad.
     
  6. whitexroft

    whitexroft

    Joined:
    Oct 22, 2012
    Posts:
    48
    And interestingly enough, it happens only to PS4 ctrl. Xbox ctrl is able to re-engage.
    I apologize to the author for the take-over of the discussion :)
     
  7. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    @whitexroft Could you file a ticket for that through the Unity bug reporter? Sounds like something that needs looking at.
     
  8. whitexroft

    whitexroft

    Joined:
    Oct 22, 2012
    Posts:
    48
    will do :)
     
    Rene-Damm likes this.
  9. Wolftousen

    Wolftousen

    Joined:
    Nov 25, 2016
    Posts:
    10

    I do have code that does your second idea, however that results in a very brief but noticeable flashing of the button. I'm using textured buttons so maybe that makes it more noticeable.

    I'll look into altering the module code. I thought about it before, but realized if i did so, i'd have to alter the file in the plugin directly since you can't tell the InputSystemUIInputModel to use a script you define given it's greyed out.
     
  10. h0neyfr0g

    h0neyfr0g

    Joined:
    Jul 13, 2019
    Posts:
    35

    Hello everyone,

    I am also facing this error, clicking outside of the UI buttons deselects them, and my controller cannot pick up the input control afterwards.

    I am trying to comment out like @Rene-Damm stated, but when I do, nothing changes in Game or Game preview. Is the following the correct location of this file? Thank you very much!

    C:\Users\*name*\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.inputsystem@1.0.0-preview.4\InputSystem\Plugins\UI