Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Button UI Not Working with The new Input system

Discussion in 'Input System' started by suiksuiky, Dec 22, 2019.

  1. suiksuiky

    suiksuiky

    Joined:
    Nov 14, 2017
    Posts:
    4
    Sorry if it's a repost but since i can't find if a tread show how to resolve that , i'm gonna Do one:

    Since i've instal the new input system on my project, every button have stop working, so i'm pretty sure i've forget something important to do , and i'm kinda looking for it !
    thanks
     
  2. suiksuiky

    suiksuiky

    Joined:
    Nov 14, 2017
    Posts:
    4
    MrZany likes this.
  3. xXshahmahXx

    xXshahmahXx

    Joined:
    Mar 30, 2020
    Posts:
    6
    guys u can use old and new input system just:go to performance>player>other setting and there is a setting wich u can choose both old and new setting
     
    Melbourne and sarahfoojn like this.
  4. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    What exactly did you do? I've setup my game with the EventSystem set to the new "Input System UI Input Module."

    When the game plays starting at a main menu all buttons work just fine, but when I load a level that has a PlayerInput component in it, the UI buttons stop working in all of my menus.
     
  5. Skotrap7

    Skotrap7

    Joined:
    May 24, 2018
    Posts:
    125
    Well, I found the culprit for me at least. After writing the above, I had noticed that the input action asset in my event system was the default asset, and the asset for my player input was not. And that got me thinking...

    So, I set my event system to the same asset as my player input, and voila my buttons stopped working completely. Then, I went to look at the actions to see what was different and I noticed that I had setup my UI /Click action with a "Release Only" interaction in order to prevent getting the double performed event calls. So, I changed it to "Press Only" and now everything works just fine.

    This has me suspect that even Unity thinks that this whole multiple firing of events thing is wrong and has implemented their UI stuff to only work the press part of the event only.
     
    burnsky likes this.
  6. tacman1123

    tacman1123

    Joined:
    Sep 14, 2020
    Posts:
    77
    I tried several variations, in the end the only way I could make my canvas elements respond to input was to switch the Player settings for Active Input Handling from Input System to both. Then I deleted the Event System in the scene and re-added it, letting it default to the old input manager.

    Curiously, the problem occurred ONLY in the editor. When I built the project using the new Input System only, the slider responded as expected.

    FWIW, I'm running 2019.4.16 under Ubuntu.
     
  7. inkletom

    inkletom

    Joined:
    Oct 13, 2016
    Posts:
    63
    We've had this too. Adding InputSystemUIInputModule didn't work for us. I've no doubt we're missing something that we don't know about but it's pretty dreadful that this system blocks fundamentals from working. I think we're going to swap back to InControl.
     
  8. bjornsyse

    bjornsyse

    Joined:
    Mar 28, 2017
    Posts:
    76
    I'm having problems in conjunction with my XR rig. Menu and buttons works until I put on my Oculus headset and it goes out of standby, then buttons stop working. If I wait for the Oculus headset image to freeze again, they start working.
     
  9. RVDH

    RVDH

    Joined:
    Aug 4, 2019
    Posts:
    5
    I am working on my first serious 2d afterwork unity project.
    Was confronted with the issue that my UI Button was not clickable anymore after loading another scene, too.
    Was first only using the new input system. Then did set the PLAYER to make use of both as described above. Was deleting the EventSystem and add it again. But it still was not working after loading my current problem scene from another scene.
    Finally was the problem that "MyOnClick" public callback method was implemented in a "MySceneMainScript" which was just attached to an empty game object "MySceneMain".
    But "MySceneMain" was not only attaching this script. There were also two other scripts attached to it. One of them was including DontDestroyOnLoad(..). And that was my fault / the pitfall.
    During executing the scene loaded from another scene, I did look into the inspector, clicked on the button, activated the DEBUG view of the properties and saw that the TARGET nested inside the ON CLICK node structure was empty, although it has been assigned before correctly.
    Probably because the TARGET script was moved in the persistent DontDestroyOnLoad(..) at runtime in the inspector view, it was not reachable from the UI button anymore. The UI button and its parent CANVAS was of cause in the normal/NOT DoNotDestroyOnLoad section. This persistent script was already instantiated by the previous scene. And the current scene was not able to do so resulting with a destroy(gameObject) within the persistent script.
    After removing that persistent script of my gameobject "MySceneMain" which was including the on click callback action it was fixed.
    When I run the scene stand alone it work because the persistent script part could be instantiated correctly and would not destroy the current gameobject to keep only one persistent object of itseld at all. Because this it was working stand alone.
    Did of cause then assign the persistent script to another empty gameobject independent from my UI reactions/callbacks to be able to run/test the scene standalone regardless of my solution workflow.
     
  10. theembracedone

    theembracedone

    Joined:
    Jul 31, 2019
    Posts:
    17
    Just wanted to add to this thread in case it helps someone in the future, I had an issue where mouse pointer was not detected by UI at all, but ONLY in a build/build and run, in editor it worked.

    I put the PlayerInput on a separate GameObject from the EventSystem and the rest, then set the binding of the mouse left and right click actions in the action map to interaction: press only. My thread is here for reference, with more details about my project setup. Hope this helps someone in the future.
     
  11. renars_s

    renars_s

    Joined:
    Nov 13, 2019
    Posts:
    2
    Check if simulate touch input from mouse or pen option is off .
    Under : Window - Analysis - Input Debugger - Option - simulate touch input from mouse or pen.
     
    Chimoru, deivid-01, N8W1nD and 5 others like this.
  12. AlexHntk

    AlexHntk

    Joined:
    May 6, 2015
    Posts:
    35
    I'll just chime in with my fix, just in case it's the issue for others; my main menu screen was responding to input, but as soon as I clicked on my Options menu it would no longer respond. I just needed to select a button on the next menu (so for me it was Options Button, list of On Click events >> "Button" >> Select() ). Probably not the fix for most, but worth checking, I was chasing my tail for a while over that one.
     
  13. josenajarqs

    josenajarqs

    Joined:
    Jan 27, 2021
    Posts:
    22
    Does anyone know how to solve this type of error?
     

    Attached Files:

  14. Ommageden

    Ommageden

    Joined:
    Sep 24, 2020
    Posts:
    7
    Currently seem to be having an issue related where my slider is only changable with arrow keys, and clicking and dragging does nothing. Only happens on the scene where there is actually player input objects.
     
  15. josenajarqs

    josenajarqs

    Joined:
    Jan 27, 2021
    Posts:
    22
    I had to put my player's object in the menu scene, although this is not good at all. But now everything works fine, and I've been looking for a method similar to WithControlExcluding(samekeythatwaspressedBefore).
     
  16. A_Marraff

    A_Marraff

    Joined:
    Dec 12, 2015
    Posts:
    2
    My fix was ridiculously simple, and I hope it is able to help someone else:
    My controller and keyboard navigation inputs were working with selecting and pressing buttons, but my mouse wasn't able to highlight or press them at all. In my input actions asset, under my "MenuNavigation" action map, the control I created for "Point" was storing the mouse delta in a vector 2 instead of the mouse position :oops: An easy to overlook semantic error, but it fixed my problem!
     
  17. James-DeCarlo

    James-DeCarlo

    Joined:
    Dec 6, 2015
    Posts:
    6
    For me it was setting the Pointer Behavior to "All Pointer As Is"
    Simple fix but works!
     
    forestrf likes this.
  18. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    147
    "All Pointer As Is" did the trick for me too, thank you. This all is very complex, I wonder if it could be simplified.
     
  19. PeterGost

    PeterGost

    Joined:
    Jan 27, 2020
    Posts:
    9
    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
     
    Szappy, Enzi and seekerxun like this.
  20. RogueStargun

    RogueStargun

    Joined:
    Aug 5, 2018
    Posts:
    218
    This was actually a feature that was previously working but seems to be broken in more recent releases of the InputSystem. My Onscreen buttons do not work at all, even in my older projects.
     
    monashayeghi92 and RazorSquirrel like this.
  21. RazorSquirrel

    RazorSquirrel

    Joined:
    Aug 30, 2015
    Posts:
    2
    For me, everything works until another menu is opened. Then only gamepad and keyboard input work, no pointer.
    This is unacceptable for a game targeted to android and iOS.
    A week spent redoing the menu system and attempting to get it working consistently has gone nowhere.
    Any word on how to use the input system in multi-scene projects with multiple menus and pointer control would be mightily appreciated.
     
  22. MCF33

    MCF33

    Joined:
    May 18, 2021
    Posts:
    1
  23. RogueStargun

    RogueStargun

    Joined:
    Aug 5, 2018
    Posts:
    218
    Update. Many of my problems stem from having multiple scenes loaded. Very often the base scene will automatically create a new event system at runtime and/or input manager which will mess with ui. I solved this by always having an initializer base scene with the appropriate input managers and event systems
     
    Tom163 likes this.
  24. HunterAhlquist

    HunterAhlquist

    Joined:
    Oct 6, 2013
    Posts:
    83
    Where is this "All Pointer As Is" option?
     
  25. HunterAhlquist

    HunterAhlquist

    Joined:
    Oct 6, 2013
    Posts:
    83
    I found it under the InputSystemUIInputModule, but it didn't work for me.
     
    Biochromatic likes this.
  26. zeromilesvega

    zeromilesvega

    Joined:
    Jan 4, 2016
    Posts:
    6
    I'm having the same issue. Trying out the Playground scene, enabled the UI, set All Pointer As Is, Simulate Touch, though it also doesn't work on a mobile build anyway...Added my own button to the mix, clicking or even mouse over events aren't detected, like something is blocking the entire canvas. I checked the Canvas' Blocking Objects and Blocking Mask are indeed set to None and Everything, respectively, so that's not it, and there's nothing after the canvas in the hierarchy, even moved it below the EventSystem to be sure. I'm at a loss and time's a wastin'...
     
  27. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,228
    Just one more voice saying the new input system is buggy as hell and stuff stops working for no reason.

    I currently have a suspicion that the input asset is guilty if you customize it, because things seem to work if I use the default, and break if I use mine, even though I changed nothing in the UI part. Maybe the parsing breaks down halfway through it or something, I have no idea. Trying to isolate the problem now, which is hell because it works in the editor.
     
    amiel_ace likes this.
  28. unity_InCZiY_4AM8_lw

    unity_InCZiY_4AM8_lw

    Joined:
    Oct 29, 2018
    Posts:
    1
    I fixed it by adding inputsystem settings to input settings.
     
  29. zeromilesvega

    zeromilesvega

    Joined:
    Jan 4, 2016
    Posts:
    6
    Before pressing play, here's the "UI_EventSystem" object from the Playground scene. Note the Input System UI Input Module...
    upload_2022-1-12_19-54-49.png

    And here's after pressing Play. There are no options for UI / Point, etc, only Player / Move etc...

    upload_2022-1-12_20-2-37.png

    Looks like it's the Actions Asset that is set to the StarterAssets Input Action Asset at some point during the loading process.
     

    Attached Files:

  30. zeromilesvega

    zeromilesvega

    Joined:
    Jan 4, 2016
    Posts:
    6
    Turns out the PlayerArmature object's Player Input component is what was setting the Input System UI Input Module's Action Asset. However, tho giving the Player Input the DefaultInputActions did indeed prevent the Input System UI Input Module from changing, it didn't fix the fact that no UI input is being detected.

    Changing the Input System UI Input Module back to the Standalone Input Module did fix it, tho. There's a warning that I have the old Input System disabled, but i don't and it works even with the red warning. Warning did not go away upon restarting, either. Still works, so guess that's a "solved?" for me, at least...

    Still would like to know how to get the *new* UI Input System working properly, rather than having to use this hybrid.
     
  31. RogueStargun

    RogueStargun

    Joined:
    Aug 5, 2018
    Posts:
    218
    The new input system is a bit wonky in that it gives you multiple ways to setup input actions including attaching "Player Input Components". This is not actually a good way of using the new input system. Instead, I'd recommend following the advice in this video:


    Create a scriptable object event channel, and route all your player inputs through that asset. It's much more flexible and will avoid the sort of issues you have encountered.
     
  32. tomtefar

    tomtefar

    Joined:
    Mar 19, 2015
    Posts:
    6
    My UI elements suddenly stopped receiving events after I tried to add new actions to my menu navigation action map in my custom InputActionsAsset (set to Generate C# class).

    After removing both the "Multiplayer Event System (Script)" and the "Input System UI Input Module (Script)" components and then simply adding them back again (making sure that the "Input System UI Input Module" was set to use my custom InputActionsAsset) everything worked fine again. Weird.
     
    amiel_ace likes this.
  33. taedal5

    taedal5

    Joined:
    Feb 2, 2021
    Posts:
    10
    The updating to 1.2.0 input system that came with UNITY 2020.3.24f1 seems to break my UI .onClick event behaviour - (previosuly working perfectly). The input action is set to Button. I can only get it to work by setting it to Pass Though. Seems like a bug? Why should that require pass through?

    Some of the above behaviour (eg replacing the input module to make it work) - may be due to doing so resetting the Action Asset to the DefaultInputActions including with the package, which has UI clicks set to Pass Through.
     
    amiel_ace likes this.
  34. jeffman1

    jeffman1

    Joined:
    Oct 21, 2013
    Posts:
    36
    For those wondering, I have a repeatable solution to this which works with the new input system and old disabled. I used a combination of techniques above. If you have the third person starter asset this is reproduceable. Here's what I did:
    1. I added code to the update section of my third person starter assets thirdpersoncontroller script (you can do this with the first person script but it needs to be added in the update of player movement or before any object's movement code):
    Code (CSharp):
    1. private void Update()
    2.         {
    3.             _hasAnimator = TryGetComponent(out _animator);
    4.  
    5.    
    6.             if (_input.PauseState == false)
    7.             {
    8.                 Time.timeScale = 1f;
    9.                 _pauseMenu.SetActive(false);
    10.             }
    11.             if (_input.PauseState == true)
    12.             {
    13.                 Time.timeScale = 0f;
    14.                 _pauseMenu.SetActive(true);
    15.             }
    16.             JumpAndGravity();
    17.             SlingPrimingCheck();
    18.             RockThrowCheck();
    19.             GroundedCheck();
    20.             Move();
    21.             StartAim();
    22.    
    23.         }
    Note: PauseState is checking for a button from the inputs script of thirdperson.
    2. I set a variable called PauseState from my inputs script but a global variable will work as well:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.EventSystems;
    5. using StarterAssets;
    6. public class PauseMenu : MonoBehaviour
    7. {
    8.   [SerializeField] private GameObject _pauseMenu;
    9.     [SerializeField] private GameObject player;
    10.     private StarterAssetsInputs _input;
    11.     private void Start()
    12.     {
    13.         player = GameObject.FindGameObjectWithTag("Player");
    14.         _input = player.GetComponent<StarterAssetsInputs>();
    15.     }
    16.    // private void Update()
    17. //   {
    18.  
    19.            // ResumeGame();
    20.  
    21.   //  }
    22.     public void QuitGame()
    23.     {
    24.         Application.Quit();
    25.     }
    26.     //public void Pause()
    27.     //{
    28.  
    29.     //}
    30.     public void ResumeGame()
    31.     {
    32.         //if (_input.PauseState == false)
    33.         // {
    34.         Debug.Log("Resuming Game!");
    35.         _input.PauseState = false;
    36.          //   Time.timeScale = 1.0f;
    37.            // _pauseMenu.SetActive(false);
    38.        // }
    39.     }
    40. }
    3. Here is my eventsystem and I for safety checked the default menu item for stability as mentioned from the forum threads:
    eventsystem.png
    4. Copy the UI from the default starters asset package installation folder to your custom input action assets file with your control mappings and map the ActionAssets of Input System UI Input Module to your custom Input Action Assets file (Yes, it's that easy and I use my custom ActionAssets file above).
    Note: I will put pause and unpause code in different methods to allow for animations later if I want them but wanted clarity for everyone above. Also, timeScale does work as well still. Also, for some reason mouse click works wonky but you can use Xbox controller if you map a button into the click part of UI on your custom Input Action Assets file. Maybe their is a mapping I am missing for the UI part of my Input Action Assets file.
     
    Last edited: Feb 11, 2022
  35. Wippo

    Wippo

    Joined:
    Jan 2, 2015
    Posts:
    4
    My Solution to this Problem was leaving the UI Input Module in the Player Input Script empty.
    As soon as I assigned my Eventsystem to it, all buttons stopped working.
    upload_2022-2-25_15-5-12.png
    It did not matter whether I used my Controls Input Action Asset (with reassigned actions for each entry) or the DefaultInput Actions in the Input System UI Input Module.
     
  36. Seerslab_App

    Seerslab_App

    Joined:
    Nov 15, 2018
    Posts:
    2

    Thanks a lot
     
    N8W1nD likes this.
  37. JanBaining

    JanBaining

    Joined:
    May 20, 2021
    Posts:
    1
    I've got another solution. Make sure that the button you want to use isnt blocked by another UI Element(The other UIE would be under your Button in the hierachy). If there is a UIE, just disable "Raycast Target" on the Image Component and if you also have a Canvas Group on your UI Element disable "Interactable" and "Blocks Raycasts".
    But this only applies if the UI Element lays on top your Button.
    Hope that helps
     
  38. M929djie

    M929djie

    Joined:
    Apr 20, 2022
    Posts:
    4
    I had to add the "Input System UI Input Module" to the UI canvas manually, which solved the issue.
     
    Inksuki likes this.
  39. matmc2003

    matmc2003

    Joined:
    Nov 20, 2021
    Posts:
    1
    I found a solution for my scenario. Go to the "Button" component on your button and make sure that the "Target Graphic" is set to the graphic of the button you're trying to change. My problem was just not being able to highlight.
     
  40. SaulChow

    SaulChow

    Joined:
    Mar 23, 2021
    Posts:
    9
    I fix that by added PlayerInput and InputSystemUIInputModule on the prefab object and drop Input~Module to the PlayerInput component.
    I think there are something need to check if you have this issue:
    https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Components.html

    The chapter UI input: "To set this up, assign a reference to a InputSystemUIInputModule component in the UI Input Module field of the PlayerInput component. The PlayerInput and InputSystemUIInputModule components should be configured to work with the same InputActionAsset for this to work."

    I found if you drop an Input~Module to the field "UI Input Module" on PlayerInput component, sometimes it will show you a button "Fix ~~~". It means the PlayerInput's has something wrong with the Inputs~~Module due to different action asset(?) or other(?) I don't know.

    So I think I need make everything has been done before enter play mode. Using script to dynamic assign the reference of Input~Module to PlayerInput will has no chance to push the "FIX" button on PlayerInput.
     
  41. Capgar

    Capgar

    Joined:
    Jul 7, 2017
    Posts:
    1
    Just my 2 cents. I thought I had an issue with the input system but instead, my "Graphic Raycaster" component was disabled on my canvas.
     
  42. Dragon_Scales_VR

    Dragon_Scales_VR

    Joined:
    Oct 5, 2021
    Posts:
    2
    I've been kicking this build for a week. Finally fixed the mobile UI issue. Not even sure what part fixed it this time but I will share a few of the things in my recent update in hopes it helps.

    I wanted multiple touch points, 1 for screen look, 1 for movement with an onscreen stick controller.

    1) I used built-in "on-screen stick" script after programming 2 of my own that didn't work.
    2) I added the "Multiplayer Event System" module to the joystick graphic (set to UI under a canvas also set to UI layer)
    3) player root is the joystick, no first selected, I did not replace standalone input module with anything, set active check box at the bottom.
    4) the image is set to raycast target or you can't click on it. Feel free to hit me up if you have any questions, info on website for Dragon Scales VR. Thanks everyone for your input. I need sleep.
     
  43. celinedrules

    celinedrules

    Joined:
    Jan 31, 2013
    Posts:
    13
    For me, I had several issues mainly due to the third person controller. I couldn't get the 'StarterAssets' actions to work with the UI but when i switched it to 'DefaultInputActions' it worked but my camera movement was very slow. I noticed that under 'Use in control scheme for the default it showed as 'Keyboard&Mouse' but in the starter asset it just showed as 'KeyboardMouse'.



    I went into the third person controller script and changed the line

    Code (CSharp):
    1. #if ENABLE_INPUT_SYSTEM && STARTER_ASSETS_PACKAGES_CHECKED
    2.                 return _playerInput.currentControlScheme == "KeyboardMouse";
    3. #else
    4.                 return false;
    5. #endif
    replacing "KeyboardMouse" with "Keyboard&Mouse" and the camera worked as expected.

    After some more digging in 'StarterAssets' actions, I noticed that under the 'Point' and 'Click' actions, under the 'Use in control scheme', that 'KeyboardMouse' was not checked for either one. Once I did that, the starter input asset worked with the UI.

    Stupid Checkbox!
     
  44. rusavladev

    rusavladev

    Joined:
    Oct 6, 2020
    Posts:
    3
    Hey guys, In my case, the solution was adding mouse as supported device in ProjectSettings>InputSystemPackage
     
  45. CCrowell

    CCrowell

    Joined:
    Mar 31, 2022
    Posts:
    5
    This was my issue as well. The only device I had in the list was Keyboard. Thanks!
     
  46. N8W1nD

    N8W1nD

    Joined:
    Sep 3, 2020
    Posts:
    5
    In my case I went to the Window > Analysis > Input Debugger, and it told me, I need to activate the new Input System in player settings (Edit > Project Settings > Player > Other Settings > Configuration > Active Input Handling)... Now it works :D See picture for correct setting (even though both should work as well :D) wow.PNG
     
  47. Nianyi_Wang

    Nianyi_Wang

    Joined:
    Sep 9, 2021
    Posts:
    5
    Bump. In my case everything works fine (pointing, highlighting, etc.) except when I click. I mean the buttons do react to clicks as they are dimmed, but no further events are fired. I tried to print a log in the button's onClick event but none came out.
     
  48. qleb1984

    qleb1984

    Joined:
    Aug 15, 2018
    Posts:
    15
    did u find a fix for this? i have same issue
     
  49. Slashbot64

    Slashbot64

    Joined:
    Jun 15, 2020
    Posts:
    171
    How in the hell was is this off... I don't get it.. this super hidden option was the reason none of my ugui stuff was working with mouse clicks..
     
  50. DYV

    DYV

    Joined:
    Aug 10, 2015
    Posts:
    45
    In my case, I should disable Cursor Locked in Starter Assets Inputs of PlayerArmature