Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Buttons don't react with Input System UI Input Module in scene

Discussion in 'Input System' started by TimedragonX, Sep 22, 2019.

  1. TimedragonX

    TimedragonX

    Joined:
    Nov 3, 2017
    Posts:
    9
    So I don't know if I'm just missing something obvious, but when I replace the Standard Input Module with the Input System UI Input Module, the UI buttons do not react to the mouse at all. No matter what I do, there is no change whatsoever.

    I even made an empty project where I placed some buttons and added the Input System UI Input Module, but there's still no reaction.

    I then checked the Tanks Demo to see if the buttons on the Rebind scene work and they do work there. I don't see what it did differently though. Is there something else I need to do in order to get UI elements to work with the new input system?
     
    synthc and Laicasaane like this.
  2. TimedragonX

    TimedragonX

    Joined:
    Nov 3, 2017
    Posts:
    9
    So I played around with the components a bit and I noticed that once you add a PlayerInput component, the UI stops reacting to the mouse, even though I set it up to have the UI as the default action map. Once I remove the PlayerInput component, the UI works again.

    EDIT: This is only the case in the empty test project I made. In my regular project the UI buttons still don't react, even after removing the PlayerInput component.
     
    Last edited: Sep 22, 2019
    Kogar, bjornsyse and JonasMumm like this.
  3. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Can you submit a bug report with your project attached, and post the case number here? Then we can check out what's wrong.
     
  4. TimedragonX

    TimedragonX

    Joined:
    Nov 3, 2017
    Posts:
    9
    I've submitted a bug report, but I haven't gotten any confirmation mail and I can't seem to find it on the bug tracker either.
     
  5. jne0xff

    jne0xff

    Joined:
    Jul 13, 2015
    Posts:
    7
    I'm encountering exactly the same behaviour. I took OnScreenControlSample from 0.9.5 scene as a basis, added an object with the PlayerInput component attached, and all the UI buttons stopped reacting. When I start the game with this object disabled, buttons work. But as soon as I enable this object in the run-time, buttons stop reacting. Notable thing is that when I disable this object during run-time again, I start receiving these errors in the log with each mouse input event (at least clicking and scrolling):
    Code (Text):
    1. Should not get here
    2. UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
    3. UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/Input/Private/Input.cs:120)
    I'm not sure if the above-mentioned bug report is successfully submitted; in case it didn't I can provide a minimum project with the reproducible bug

    Can reproduce it in both 0.9.5 & 1.0.0
     
    Last edited: Oct 3, 2019
    bjornsyse likes this.
  6. jne0xff

    jne0xff

    Joined:
    Jul 13, 2015
    Posts:
    7
    Just in case: here is the project with this issue. Also I submitted the bug as well and here is the link to the ticket: https://fogbugz.unity3d.com/default.asp?1188763_f18epehmhhnfc26i.
    Couple of other noticed things: the OnScreenControlSample includes an old "Standalone Input Module" instead of the new "Input System UI Input Module" on EventSystem. If I leave "Standalone Input Module", then everything works as expected. Also If PlayerInput & Input System UI Input Module have different InputActionAssets, then everything works as well
     

    Attached Files:

    bjornsyse and seffles like this.
  7. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Can confirm, when I switched the Standalone Input to InputSystemUIInput, it automatically assigned the InputAsset at Packages/InputSystem/InputSystem/Plugins/PlayerInput and UI works. I then duplicated the UI action map from there to my InputAssets. Now if I select my InputAsset in the InputSystemUIInputModule, nothing works, if I use the default one, it does even if they are both the exact same.
     
    bjornsyse likes this.
  8. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    @jne0xff Thank you for submitting a ticket with the repro. We'll take a look.

    ////EDIT: Just saw it was closed as a duplicate. But no worries, we have it tracked.
     
    jne0xff likes this.
  9. TimedragonX

    TimedragonX

    Joined:
    Nov 3, 2017
    Posts:
    9
    My bug report finally came through. Here's the case number: 1187185
     
    Rene-Damm likes this.
  10. Mat_os

    Mat_os

    Joined:
    May 11, 2018
    Posts:
    4
    Same Problem :(
    I fix it like that: on the "Event Handler" delete "Input System Ui Input Module" and add component "Standalone Input Module".
     
  11. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    That's not really a fix, as you're probably using "both" input handling and it just uses the old one
     
  12. ZedCell

    ZedCell

    Joined:
    Feb 24, 2019
    Posts:
    1
    Having a similar issue to this - when I have two gameobjects with Player Input scripts attached and a UI Input System Module, after going into play mode the ActionsAsset on the UI Player Input Script and UI Input System Module both change to a new asset called [MyAssetName] (Clone) and all the UI functionality breaks.

    In Editor (out of Play mode):
    upload_2019-11-27_23-35-5.png

    After changing to play mode:
    upload_2019-11-27_23-35-50.png

    Will send a bug report too.
     
    Last edited: Nov 28, 2019
    Yukki_ likes this.
  13. shaq145

    shaq145

    Joined:
    Jan 23, 2017
    Posts:
    8
    can someone help me? I have the same problem. InputSystemUIInputModule is commented out and I can't find the MultiplayerEventSystem. My PlayerInput doesn't have an AutoSwitch too. I'm using Unity 2019.1.12f1
     
  14. braur

    braur

    Joined:
    Jan 7, 2018
    Posts:
    7
    I've been trying to use the new Input System for months now and despite v. 1.0.0 it is still kinda garbage...
    Like this InputSystemUIInputModule - it is recommended to use it, but... it simply does not work in my project. Documentation really sucks, there are no good examples nor tutorial videos on this topic, etc. That would be understandable if we have v. 0.2 or sth, but 1.0.0? Really, guys?
    What is more, I believe that the new Input System messes with the old one (Standalone Input Module for example) and thus I receive my UI calls twice somehow.
    As for July 2020 I strongly advise anyone to not use the Input System.
     
    zwcloud, Kogar, mowax74 and 3 others like this.
  15. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    760
    What's the latest news on this?
     
  16. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    760
    I was reading about this in the "known limitations" section of the manual ( https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/KnownLimitations.html ). It says "After enabling, the UI will not react to a pointer's position until the position is changed." I think that might be a typo... I read it and was like... "After enabling what?" I suspect it meant to read: "After enabling PlayerInput", and I'm pretty sure that known limitation is the same bug found in this thread.
     
    Last edited: Aug 19, 2020
  17. connororton94

    connororton94

    Joined:
    Apr 19, 2019
    Posts:
    2
    Still getting this bug as of 25/09/20 in Unity 2020.2.0b2, I have to use the old Standalone Input Module for my UI to react again. Wouldn't mind knowing the status of this bug. :)

    Edit: This was my bad, I made my input action asset roughly a year ago and forgot that I made it keyboard only. Added mouse onto the control scheme and everything, interacting with ui with mouse etc works perfectly! This might help others:

    Resolved.png
     
    Last edited: Sep 26, 2020
  18. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
  19. masak

    masak

    Joined:
    Aug 14, 2011
    Posts:
    52
    This bug does not fixed in some environments. I sent a bug report.
    PlayerInput + InputSystemWithInputModule + ActiveInputHandling:both kills uGUI buttons.
    PlayerInput + StandaloneInputModule + ActiveInputHandlong:both works well.

    I think that people who got this bug are about 5% of user who bought my game.
     
    tknippenberg likes this.
  20. PeaQew

    PeaQew

    Joined:
    Apr 22, 2017
    Posts:
    3
    Any information on a fix for "After enabling, the UI will not react to a pointer's position until the position is changed." (Found here)? This is an issue when the mouse pointer is stationary and an UI element moves under it. It currently does not trigger PointerEnter, PointerExit events etc. until the pointer is moved again.
     
  21. wellthisisfunsoftware

    wellthisisfunsoftware

    Joined:
    Oct 12, 2020
    Posts:
    2
    I have banged my head against the wall on this one, but I have found a suitable code solution that fixes what's broke.

    When you don't explicitly set your ActionMap then it enables all of them together, or at least UI+Player. The problem I was having was disabling the Player, allowing UI, then once the UI closed, re-enabling UI+Player, while not enabling some additional ActionMaps.

    The proceeding code switches to a single ActionMap then forces the UI mode on while not disabling the Player action map.

    Code (CSharp):
    1.             _playerInput.SwitchCurrentActionMap("Player");
    2.             _playerInput.actions.FindActionMap("UI").Enable();
    3.  
    Here is the full helper class thus far:
    Code (CSharp):
    1.     public class InputStateMgr
    2.     {
    3.         public bool InputDisabled { get; private set; }
    4.  
    5.         private readonly PlayerInput _playerInput = GameObject.Find("Keyboard-EventSystem").GetComponent<PlayerInput>();
    6.         private readonly InputSystemUIInputModule _inputSystem = GameObject.Find("Keyboard-EventSystem").GetComponent<InputSystemUIInputModule>();
    7.        
    8.         /// <summary>
    9.         /// Switches to the UI action map which is typically used in UI dialogs
    10.         /// </summary>
    11.         internal void SwitchToUIActionMap()
    12.         {
    13.             InputDisabled = false;
    14.             _playerInput.SwitchCurrentActionMap("UI");
    15.            
    16.             EventSystem.current.SetSelectedGameObject(null);
    17.         }
    18.  
    19.         /// <summary>
    20.         /// Switches the player action map which is uses player input as well as some on screen UI elements
    21.         /// </summary>
    22.         public void SwitchToPlayerActionMap()
    23.         {
    24.             InputDisabled = false;
    25.             _playerInput.SwitchCurrentActionMap("Player");
    26.             _playerInput.actions.FindActionMap("UI").Enable();
    27.  
    28.             EventSystem.current.SetSelectedGameObject(null);
    29.         }
    30.  
    31.         /// <summary>
    32.         /// Enables the AnyKey to close input handling for showing Signs
    33.         /// </summary>
    34.         public void SwitchToSignUIActionMap()
    35.         {
    36.             InputDisabled = false;
    37.             _playerInput.SwitchCurrentActionMap("Sign UI");
    38.            
    39.             EventSystem.current.SetSelectedGameObject(null);
    40.         }
    41.  
    42.         public void DisableAllInput()
    43.         {
    44.             InputDisabled = true;
    45.             _playerInput.SwitchCurrentActionMap("NoInput");
    46.         }
    47.     }
    48. }
    Also make sure you haven't copied (at least for me) the UI actions (ie. Click or Pointer) to the Player ActionMap, just leave them be and make sure you Input System UI Input Module is using the UI actions.

    upload_2020-11-21_9-36-30.png

    Hope this helps someone.
     
  22. Ahmadhp

    Ahmadhp

    Joined:
    May 31, 2013
    Posts:
    33
  23. henn1ng

    henn1ng

    Joined:
    Apr 29, 2020
    Posts:
    3
    Hey everyone!

    I also just ran into this. The button doesn't trigger the assigned event in the actions asset. @wellthisisfunsoftware will try your approach!
     
  24. lifzgreat

    lifzgreat

    Joined:
    Nov 28, 2020
    Posts:
    1
    @wellthisisfunsoftware Thanks, I was using the left mouse button action in both the UI and the Player maps. Reading your advice, I deleted the one in the Player map. Our game moves the player by clicking/tapping and also has UI buttons onscreen (normal stuff like attack, open inventory, etc). Using the new Input System, when I click a button, the player also moves. How do we keep the move from happening when the player just intends to click the onscreen buttons?

    Edit:
    I ended up using the below code at the top of my player's click/tap handler. That fixed it - now it doesn't move the character when a button is clicked.
    Code (CSharp):
    1. if (EventSystem.current.IsPointerOverGameObject()) return;
     
    Last edited: Dec 13, 2020
  25. CesilCo

    CesilCo

    Joined:
    Feb 8, 2021
    Posts:
    2
    I'm still currently testing but I manage to get something by duplicating the defaultInputActions.inputactions file from the Packages >> Input System >> InputSystem >> Plugins >> PlayerInput.

    I realized that that .inputactions has a UI Action Maps. I added more Action Maps and did some testing, the added action maps works and buttons are somewhat reacting as well.

    Just sharing this now so that more developers can test this with me and hopefully find a way to work around this major issue.

    Cheers
     
    Last edited: Feb 8, 2021
  26. bmsh

    bmsh

    Joined:
    Jan 1, 2018
    Posts:
    2
    After trying several other solutions, in my project I was finally able to get UI buttons to work by going under Edit / Project Settings / Input System Package and adding Mouse as one of the supported devices. Because I had earlier added Gamepad as a supported device, the input system was only detecting input from the gamepad!
     
    Jordan515922 likes this.
  27. masak

    masak

    Joined:
    Aug 14, 2011
    Posts:
    52
    https://issuetracker.unity3d.com/is...when-dualshock4-wireless-adapter-is-connected

    PlayerInput + dualShock4 wireless adapter kills any input in some environments.

    [DualShock 4 USB Wireless Adaptor] tries to connect every frame even if you do not touch.
    And PlayerInput. OnUnpairedDeviceUsed is called.
    And using (InputActionRebindingExtensions.DeferBindingResolution()) is called.
    Before leave the block, DeferBindingResolutionWrapper.Dispose is called.
    All input which contain signals for EventSystem are vanished!

    If you receive signals of PlayerInput via callback, works well because they are dispatched before OnUnpairedDeviceUsed.
    But if you receive signals of PlayerInput as polling (i.e. InputAction), they are vanished.
    EventSystem also can not react because EventSystem.Update is called after OnUnpairedDeviceUsed, all signals have already been vanished.
     
    Last edited: Mar 4, 2021
  28. PeterGost

    PeterGost

    Joined:
    Jan 27, 2020
    Posts:
    18
    Had the same issue. Make sure that the input system package, does not have any devices inside... It worked for me after migrating from the Previous Input System

    Screenshot 2021-03-22 at 11.59.56.png
     
    JustAKgiDev and Jordan515922 like this.
  29. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    225
    This still seems in a pretty confusing state, to me anyway. I am having this problem and having trouble understanding things clearly. Considering the Input System is a 1.0 release and UI Toolkit is a 1.0 preview should we not expect something more approachable?

    I have my "Active Input Handling" set to "Both". Thought this would be good so I can migrate to the new system while I do other things. However, having the same problem as the OP, UI Toolkit buttons aren't working and it seems some ray tracing stuff stopped working.

    Does UI Toolkit not work with "Both"? Is there a chance things are working better in Unity 2021? (I plan on upgrading to that in the near future anyway.)
     
    lclemens likes this.
  30. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    225
  31. DSivtsov

    DSivtsov

    Joined:
    Feb 20, 2019
    Posts:
    151
  32. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    760
    Code (CSharp):
    1. ////FIXME: The UI is currently not reacting to pointers until they are moved after the UI module has been enabled. What needs to
    2. ////       happen is that point, trackedDevicePosition, and trackedDeviceOrientation have initial state checks. However, for touch,
    3. ////       we do *not* want to react to the initial value as then we also get presses (unlike with other pointers). Argh.
    4.  
    5. ////REVIEW: I think this would be much better served by having a composite type input for each of the three basic types of input (pointer, navigation, tracked)
    6. ////        I.e. there'd be a PointerInput, a NavigationInput, and a TrackedInput composite. This would solve several problems in one go and make
    7. ////        it much more obvious which inputs go together.
    8. ////        NOTE: This does not actually solve the problem. Even if, for example, we have a PointerInput value struct and a PointerInputComposite
    9. ////              that binds the individual inputs to controls, and then we use it to bind touch0 as a pointer input source, there may still be multiple
    10. ////              touchscreens and thus multiple touches coming in through the same composite. This leads back to the same situation.
    11.  
    12. ////REVIEW: The current input model has too much complexity for pointer input; find a way to simplify this.
    13.  
    14. ////REVIEW: how does this/uGUI support drag-scrolls on touch? [GESTURES]
    15.  
    16. ////REVIEW: how does this/uGUI support two-finger right-clicks with touch? [GESTURES]
    17.  
    18. ////TODO: add ability to query which device was last used with any of the actions
    19. ////REVIEW: also give access to the last/current UI event?
    20.  
    21. ////TODO: ToString() method a la PointerInputModule
     
  33. amiel_ace

    amiel_ace

    Joined:
    Oct 25, 2014
    Posts:
    18
    this is so stupid, it seems like a downgrade from previously already working system. So complicated to setup waste of my time
     
  34. Croquet_Flamingo

    Croquet_Flamingo

    Joined:
    Aug 7, 2020
    Posts:
    3
    I encountered a similar bug on 2020.3.25f1
    Specifically, when I added the Input System UI Input Module, the Default Actions asset worked perfectly, but any other asset I gave it would not.
    I couldn't change the default actions asset so I could only work with it's default bindings.

    There's probably a better solution to this, but for the person who was as hopelessly lost as I was, I did this and it worked and I refuse to mess with it any further.

    I deleted my original Event System game object and just added the components (event system and UI input module) to my player.
    Under Package Manager (Window -> Package Manager) I imported the "Rebinding UI" sample under the Input System. With this asset, I was able to customize and save like with my own Input Action assets, but it also magically worked like the Default Actions Asset would. I have no idea why.
     
  35. amiel_ace

    amiel_ace

    Joined:
    Oct 25, 2014
    Posts:
    18
    Its 2022 and still this very fundamental input bullshit is still not working properly, damn unity
     
    angelonit, a_halber and YujenDev like this.
  36. MikeSemicolonD

    MikeSemicolonD

    Joined:
    Jan 24, 2022
    Posts:
    1
    I found a work around to setting my bindings and having the UIInputModule actually use it.


    Code (CSharp):
    1. InputSystemUIInputModule.actionsAsset.LoadBindingOverridesFromJson(controls.SaveBindingOverridesAsJson());
    This is complete overkill but hey at least it'll recognize it now..

    I would try to swap the Cancel and Submit buttons and it just wouldn't work. InputControls would register as being overridden but the UIInputModule would not respond to those new changes. :(



    I also noticed a bug where if I set the module's actionsAsset to my newly binded controls it pays attention to it for ONLY the first input. So after I press Submit once it doesn't work anymore. To get it to work I had to constantly disable and re-enable the input module every time I press Submit. (Of course I'm not gonna do that, hence the JSON save load solution)

    I hope this helps someone. Hopefully this gets fixed.
     
  37. Velcrohead

    Velcrohead

    Joined:
    Apr 26, 2014
    Posts:
    78
    Where does this go?

    EDIT : Not sure if this will help, but if you duplicate the default in file browser, copy it over to assets, this still worked for me. Not had to add any mappings yet but might be worth a shot?
     
    Last edited: Jan 29, 2022
  38. Schizoid2k

    Schizoid2k

    Joined:
    May 6, 2015
    Posts:
    40
    I wish I knew what was going on with the Input System... it seems overly complex to get it working, even after reading tons of threads and watching videos. Docs and videos make it seem so simple until you want to access UI items.

    Under no circumstance can I get UI objects to respond to the input system when I create my own Input Actions object... buttons do not respond. If I take a copy of DefaultInputActions (like a previous poster stated) and place it in my project, everything works. So I guess I will use a copy of DefaultInputActions and strip out all the stuff I do not need in order to move forward, although it is a bit concerning as I am testing with mouse input and want to add touch at some point.
     
    yuukiandhisaxies likes this.
  39. wujinjindx

    wujinjindx

    Joined:
    Feb 9, 2020
    Posts:
    3
    Just to help any more people who encounter this annoying issue.

    Other than the general configurations of EventSystem and Canvas, there is another cause of the irresponsive UI buttons I figured out in my own programs and I think it may be the cause for most people.

    The issue occurs when you add a camera by yourself (very common) without tagging it as MainCamera. If you have no clue of tagging it, then it is very likely to be your cause.

    key point: The camera you use with input system (old/new) must be tagged as MainCamera. Otherwise it won't recognise objects that have no collider.
     
    MurphyMurph_21 likes this.
  40. vozcn

    vozcn

    Joined:
    May 15, 2019
    Posts:
    11
    Thanks a lot! That solved my problem. Problem was control scheme as you sad in the link : "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."
    I had copied UI actions from DefaultInputActions to my InputActons by dragging them, but scheme was not copied. After manually selecting scheme for every binding, my UI started working.