Search Unity

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

Discussion in 'UGUI & TextMesh Pro' started by _eternal, Oct 27, 2021.

  1. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    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.
     
  2. kei233

    kei233

    Joined:
    Dec 16, 2019
    Posts:
    59
    1. Maybe considering block alt+enter for fullscreening. (Didn't try, don't know how.)
    2. Maybe find eventsystem, then GetComponent<StandaloneInputModule>().DeactivateModule();
    But this means disable all ui hotkey.
    Don't how to ignor one of them.
     
  3. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    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.
     
  4. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
  5. kei233

    kei233

    Joined:
    Dec 16, 2019
    Posts:
    59
    cooool~
     
  6. Master_Aricitic

    Master_Aricitic

    Joined:
    Sep 17, 2017
    Posts:
    6