UI Focus Retention

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.

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.

Is there a workaround before that happens? Like manually refreshing the system in OnApplicationFocus?

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.

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.

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 :slight_smile:

@whitexroft Could you file a ticket for that through the Unity bug reporter? Sounds like something that needs looking at.

will do :slight_smile:

1 Like

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.

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