Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Gameplay UI Unresponsive in Editor

Discussion in 'Open Projects' started by IsaiahKelly, Mar 4, 2021.

  1. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    When running the game in the editor, I noticed that none of the in-game UI components respond to mouse clicks. The main menu works just fine, but there is no response when clicking any in-game UI component, such as the inventory button or anything in the inventory panel itself.

    Apparently the UI EventSystem is not capturing any in-game input, because the protagonist will do an attack action every time I click the mouse button, whether it's over a UI component or not. One possible cause for this could be a loss of focus on the game window, but I have double checked to make sure it has focus, and the main menu and right-click to rotate camera works just fine. Only the in-game UI is not responding.

    I also took a look at various UI components in the scene while in play mode, but nothing seemed unusual and the EventSystem GameObject did indeed exist. So I am not sure what is the issue and I have never had any issue like this with any of the older Unity example projects.

    The only other input issues I have experienced like this were with the Cinemachine samples, which may also be using the new input system... So I am thinking maybe the new input system is at fault somehow?

    Anyway, just thought I would post this here to make you aware and in case someone else experiences the same issues too. It's all a real shame because I'd really love to help out with the project, but this makes it somewhat impossible :(
     
    Last edited: Mar 4, 2021
  2. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Hey @IsaiahKelly! There's actually not that much to worry about.

    As for the UI not capturing events, I noticed it too and while I didn't investigate, I think it might just be because of a missing EventSystem Gameobject in the scene? Not sure, but I wouldn't worry too much. That button will not be in the final game anyway, to open the inventory you'd press a button (either on the gamepad or on the keyboard).

    I don't think it would work in the build, it would probably behave exactly in the same way. But again: it's not a weird editor issue, it's the wrong setup on our end.

    As for the build, the reason why you don't see anything is because you haven't built AssetBundles. Check out the instructions in our wiki!

    What did you want to contribute?
     
  3. Smurjo

    Smurjo

    Joined:
    Dec 25, 2019
    Posts:
    296
    Part of it I think "It's not a bug, it's a feature" - of the new Input System. You can define different action maps for in game and when the menu is open. As a result the same input can do something different, depending on which action map is active. Given that the "Menus" action map isn't active during gameplay but the "Gameplay" action map, it is behaving as expected when not reacting.

    To complicate things even further the inputs are then processed by a scriptable object called input reader, which would raise events. If nobody listens to the events still nothing happens.

    But it obviously makes no sense to display a menu button you can't click. Since the UI is only been designed just now I guess it is simply an issue of "not finished yet".
     
  4. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    Glad to learn the build issue was just me being dumb :oops:.

    I knew the game was using AssetBundles but I am not very familiar with them or the addressable system. So I just assumed they were automatically built if needed along with the player. My bad! However, this makes me think it might be a good idea to add some kind of UI message for builds that notifies the user if there are no AssetBundles found to load. So idiots like me know why and don't just get an unhelpful blank screen.
     
  5. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Hmm, it's a bit more complicated than that, it's not the Action Maps that are at play here... since we haven't defined any action for the click in any of the Action Maps. But for both the main menu and the in-game inventory button we're using a completely different InputActions asset...

    upload_2021-3-5_1-40-1.png

    ... but again, it's all a temporary setup.

    More interestingly, I just tried and... it works for me? @IsaiahKelly, did you pull from the most recent
    main
    branch?

    If you build as a Development build it should present an in-game console, which will spit out the error when it tries to load the first AssetBundle and doesn't find it.

    upload_2021-3-5_1-41-21.png

    But regardless, it's a very easy thing to miss and I think we should improve the warning somehow... the issue is, building without building the content is actually a potential valid workflow*, so not sure when or how should this warning appear.

    * this is when you have built the content previously, or on another machine or server, and you just want to build the game.
     
  6. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    @cirocontinisio Yes I'm using the latest main branch, but it probably worked for you because you loaded the gameplay scene directly in the editor. I've now discovered that this bug only happens when you start from the Initialization scene and then load the gameplay scene.

    This discovery made me think that the problem might actually be how the EventSystem objects are getting un/loaded between scenes, since there are actually multiple non-persistent EventSystem objects in multiple scenes, and you are only supposed to ever have one at a time.

    So to test this theory I deleted the EventSystem objects located in the MainMenu and Gameplay scenes and instead placed just one in the PersistentManagers scene, and this resolved the issue!

    I can make a PR for this simple fix if you like, but we should really add some kind of functionality to make sure the EventSystem object acts like a...
    singleton :eek:
    ...to ensure this issue doesn't happen again in the future when more scenes get added. Yeah, I know we want to avoid this pattern as much as possible, but I don't know of any other easy fix for this. Maybe someone else here has a better solution?
     
    Last edited: Mar 5, 2021
  7. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    I'm currently on another branch so can't test, but thanks for the info!

    No need to make a fix now I think, unless it's blocking you from working on something... as I said, we will remove that button anyway.

    Hahahaha this made me laugh :D
     
  8. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    Hey, I am just glad you are not angry at me for making that suggestion :D

    It also sounds like only the temporary inventory button was not responding to clicks for you? Which would explain why you do not think this is a big issue. But for me it was actually the entire in-game UI that was not responding. Making the game mostly unplayable.

    Again, this makes me think you only tested the inventory scene directly, which I think works just fine in all test scenes. But if you start from the Initialization scene, and then open the inventory screen using the Q key, nothing responds to clicks there either and you are stuck on it. Which I would say is a big issue. But removing the duplicate EventSystem objects fixes all this.

    There are many code and custom editor elements I would like to try and help improve, but I am most interested in maybe improving the underlying ScriptableObject infrastructure some. However, my ideas might be too radical for the project. So I am still investigating and testing my ideas out first. In the meantime I might try to work on some of those programming to-do cards.