Search Unity

Resolved UI doesn't responds with Custom Input Assets

Discussion in 'Input System' started by DSivtsov, Jul 7, 2021.

  1. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    151
    If you decided use the New Input System with UI you can have some problem - UI wouldn't react if you use your custom Input Assets.
    By default when you create the Player Input component (by default the field UI Input Module set to None)
    DefaultPlayerInput.JPG
    If you after that create the Event System (its create automatically if you create some UI element, by example - button), It have the default value in field Action Asset (DefaultInputActions).
    In this case all will work fine, but you "Player Input system" and "UI Input system" will use different Input Action Assets (in my example, the "Player Input system" use the my custom BaseControl.inputactions).
    More correctly use the one Input Action Assets and set the field "UI Input Module" (based on official docs - you must set your InputActionAsset in "InputSystemUIInputModule" and link it to your Player Input through the field "UI Input Module")
    DefaultInputSystemUIInputModule.JPG

    BUT VERY IMPORTANT (its not writing in docs) you must have correct Control Scheme set for UI Actions (in your InputActionAsset).
    You must whether no any schemes (as on picture below) or have right scheme which will activate Action as for your Player Input System and also for UI Input System.
    InputActionsNoControlScheme.JPG
    I had problem then I set for Player Input System control scheme which used only the keyboard and its blocked any input actions to UI from mouse, because initial the mouse device was absent in my control scheme (You can set the used Control Scheme for Player Input, but for UI Input System you can't do it, it use the same).
     

    Attached Files:

    Last edited: Jul 7, 2021
    AvidPlayer and shamisen07 like this.
  2. maris-otter

    maris-otter

    Joined:
    Jun 10, 2020
    Posts:
    11
    Hello,

    Thanks for these details, I think I am experiencing the same/similar issue. I have the same playerinput and event system components as you. I have two action maps, Player (for player movement in game), and UI (for UI navigation). I am trying to switch to UI when in menus, but it doesn not work.

    Tried SwitchCurrentActionMap() function which does change the action map, but it still does not work.

    What do you mean by "You must whether no any schemes (as on picture below) or have right scheme which will activate Action as for your Player Input System and also for UI Input System."?

    This is what I have setup for my action maps, for Player. How could I not use any control schemes here, doesnt it mean the player action map wont work?

    Thanks!
     

    Attached Files:

  3. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    151
    You don't show the your Action Map for UI, and what type of control scheme you use for Player and for UI. In the scheme you must enable the all devices which you use as for Player as for UI Input. (because at now the UI can't use the separated scheme from Player)

    You must not create any scheme or create the one common scheme for Player and UI.
     
    maris-otter likes this.
  4. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    151
    In case the "No control schemes" (see on my pic) "will be active" the all devices which you use in all Action Maps

    P.S> As a Variant (I didn't check it) you can switch the control at enter and at exit from UI action (e.g. "from Menu")
     
    Last edited: Jul 19, 2021
  5. staticV01d

    staticV01d

    Joined:
    Apr 26, 2021
    Posts:
    2
    What worked for me was that when you initially add your UI element that creates the initial canvas and event system, when you click the button to have it change the standalone input module to the new input system UI module, don't touch anything, let it continue using the 'DefaultInputActions' that is shown in the InputSystemUIInputModule object when it is created, and you can still use a custom input actions asset for your player input separately.

    upload_2022-6-3_22-5-54.png
     
  6. ian1971

    ian1971

    Joined:
    Oct 12, 2017
    Posts:
    3
    Thanks for that. I spent ages trying to get it to work.
     
  7. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    151
    The post was initially about other issue
     
  8. UnkelRambo

    UnkelRambo

    Joined:
    Oct 26, 2012
    Posts:
    80
    If anybody else comes across this issue, my issue was that I LOOKED at the DefaultInputAction Control Schemes, saw that it was called "KeyboardMouse", so I named my control scheme "KeyboardMouse" as it appears here:

    upload_2023-1-16_9-38-31.png

    If you EDIT the control scheme, you'll see that it's ACTUALLY named "Keyboard&Mouse", but the ampersand (&) doesn't show up in the control scheme name in the selection UI (lel)

    To ACTUALLY fix this issue, you MUST have a control scheme named "Keyboard&Mouse" like so:
    upload_2023-1-16_9-42-37.png

    setup to use both the Keyboard and Mouse (otherwise the Player Input Manager will detect input from the keyboard and mouse as separate players.)

    with UI action map copy+pasted from the default action map asset:
    upload_2023-1-16_9-37-2.png

    Two days of my life gone because of this, hope it helps somebody else ;)
     

    Attached Files:

    mhassanpur, akast07, int32 and 5 others like this.
  9. LordTommy33

    LordTommy33

    Joined:
    Sep 12, 2017
    Posts:
    7
    OH. MY. GOD. I've had this same issue for years and it's been a constant thorn in my side with the input system. This one thing. This one fix solved all the problems I've had for YEARS. THANK YOU! Gah I don't get how Unity releases things with such silly little bugs in their systems likes this.
     
    Evalie likes this.
  10. simonbrtrnd

    simonbrtrnd

    Joined:
    Apr 1, 2020
    Posts:
    3
    Oh man, I spent literally 3 days scratching my head over this... I still can't believe that the solution was to rename my scheme to "Keyboard&Mouse". I feel relieved and super sad at the same time...
     
  11. chbcjl

    chbcjl

    Joined:
    Jan 2, 2019
    Posts:
    3
    I found it :

    1.select the scheme you want to use
    1284752-d84665925afc89154dbf1cdd0889f922.png

    2.
    1284752-d84665925afc89154dbf1cdd0889f922.png
    select the " Edit Control Scheme ".

    3.
    Add "Mouse" into list.

    4.
    60MVW~D8$3I)J4I]AR)9FHB.png

    ~8R_IDQSRJ(IWX`{YH1TODY.png
     

    Attached Files:

  12. chbcjl

    chbcjl

    Joined:
    Jan 2, 2019
    Posts:
    3
  13. berber_hunter

    berber_hunter

    Joined:
    Apr 30, 2021
    Posts:
    14
    I can't get over how bad the documentation is...
     
  14. mhassanpur

    mhassanpur

    Joined:
    Mar 25, 2020
    Posts:
    1
    Thank you!!! I was scratching my head for days, trying to figure this out...