Hello! I’ve been trying to solve this issue for a while now. In my game, when the player levels up, a level-up menu pops up, pauses the game, sets the input mode to ‘Game and UI’, and focuses the new window. That part works fine. However, after the player closes the window, the code sets the input mode back to ‘Game Only’, which causes a problem with my enhanced input system. If the player had a key held down before the pop-up appeared, the input system starts spamming ‘Started’ and ‘Completed’ events continuously. I’ve tried flushing the inputs, as well as removing and re-adding the input context, but nothing has worked so far.
Hi,
That is a strange interaction. I would have thought you would be able to avoid that with removing the IMC and then adding it again. Are you adding and removing the IMC in quick succession, or are you removing it once you open your popup, then re-adding it at a later time when the popup is closed? I would be inclined to trying the latter if you aren’t already. It might also be worthwhile playing around with the options available for adding and removing IMCs, i.e. in particular the Ignore All Pressed Keys Until Release option to see if setting it one way or the other improves the behaviour you see.
One other thought is are you able to remove the reliance on setting input modes by solely dealing with adding or removing IMCs? I could see that as another way forward.
Lastly, and this is less of a solution and more of a general recommendation, I would encourage you to look into Common UI if you haven’t already. It solves a lot of these input routing and layered UI issues, and it works a lot more seamlessly with Enhanced Input.
Thanks,
Hayden
Hello!
Thanks for replying! I’ve been racking my brain over this for the past few days even before that, really. I’m sure your suggestions would have worked if the issue hadn’t been so basic.
The problem was that I had some widgets set as focusable, and that threw everything off. Essentially, one of the widgets consumed a button input and somehow triggered an endless loop of starting and completing the enhanced input action. After disabling every focusable widget, everything started working just fine, no need to add or remove context.
Thanks again for your help!
Isfador