Making UI toggles using enhanced input?


Is there a definitive intended workflow for this?
We’re trying to set up UI toggles to show/hide the UI itself and our current approach is to split entire IMCs between pawn and UI, since UI also has more actions than just toggling itself off.

Generally speaking besides the actual toggle input everything works fine.
Behaviour of the toggle itself is all around the place really, generally even in most reliable setup there’s a weird bug where input processing seems to not consume the action.
Getting into the UI seems to work just fine no matter what while getting out by pressing the action key and HOLDING it will eventually trigger the binding on Pawn’s end. With the key word being eventually as there’s a solid second delay before it triggers, even though the input has been already processed on UI end and the key has never been released since.

We do toggle between game/ui only input modes so technically shouldn’t be an overlap in input processing and this behaviour does not replicate other way around (opening the UI from pawn and holding the key does not eventually trigger the input to close it on UI end).

Both the delay and one-way behaviour of this kind of imply to me that it’s not an entirely intended behaviour of input processing but perhaps there’s something i’m missing or there’s a workaround for this issue?

Any assistance and tips would be greatly appreciated, thanks in advance.

1 Like

Struggling to understand how you set things up. Do you have two IMCs - one for the pawn and one for the UI? How many input actions do you have to toggle the UI? One input action that is present in both IMCs or two different input actions (one for each IMC)?

I tried to set up something similar, but I can’t for the life of me get the enhanced input event to fire within the UI/widget if I set the input mode to UI Only. If I set the input mode to Game Only or Game And UI the enhanced input event inside the widget will fire. Did you set this up in a special way to get it working while using UI Only mode?

The way to go in the future I guess is CommonUI. It handles all the functionality for e.g. opening a UI (escape/settings menu) without even binding the key to open/close in one of your IMCs (it looks like it also does implicitly what I wrote below). I’m not using it right now, but it is very powerful - esp. for complex UI navigation and multi platform development.

But you can also use the following functions to enable/disable input for your current possessed Pawn:

APawn->InputEnabled() (checks if the input is enabled for this pawn)
(PC = ref. to PlayerController)

There is one IA for toggle and it is Held in one IMC (held by Pawn), input mode is changed between Game Only and UI Only respectively, so less interaction handling is required.