How do you make Unity's Event System ignore an input?

I’m currently jumping through hoops trying to deal with alt+enter behavior. If the user presses alt+enter to fullscreen the game, I want the game to ignore the enter input. Makes sense, right? Enter is also a “submit” key in my game, so the user would be accidentally pressing submit on the menu every time they press alt+enter.

I thought I could sidestep this by implementing ISubmitHandler and doing eventData.Use() if the player is holding alt. However, even if I do this, the “submit” event still gets fired.

How does this work exactly? I find it hard to visualize what’s going on inside the Event System.

  1. Maybe considering block alt+enter for fullscreening. (Didn’t try, don’t know how.)
  2. Maybe find eventsystem, then GetComponent().DeactivateModule();
    But this means disable all ui hotkey.
    Don’t how to ignor one of them.

Yeah, I realized that it’s a tricky problem to solve. I already have a funny hack where I disable the input module if the player is holding alt. This sort of works, but it doesn’t work if they press alt and enter at roughly the same time, because the event goes through before the input module can be disabled.

I booted up the first Ori game just to check, and they solved this problem somehow. But for a company of their size, they could have written their own UI system for all I know (also I think that was before uGUI).

Meanwhile, I just checked Cuphead, and… the problem exists for them, too. If you alt+enter on the title screen, the game accepts the enter input.

Well. If it’s good enough for Cuphead, then I guess it’s good enough for me. But I’ll still fix it if I can figure out how.

I figured it out! I realized in this thread that EventSystem appears in the Script Execution Order window: When are IPointerHandlers executed in the Unity life cycle?

With that in mind, you can just move your input management scripts above the EventSystem. Whether this is a good idea or not remains to be seen, because I usually don’t like to mess with execution order. But at least I can say that it’s working.

cooool~

According to this thread: Block or Override Alt-Enter Fullscreen - Questions & Answers - Unity Discussions you can outright disable the alt+enter functionality.

To do this, go to Project Settings → Player → Resolution and Presentation (under “Settings for Windows, Mac, Linux”), and it is the 10th option.