Forum rules - please read before posting.

Pause Menu - Selected Element

Driving myself mad again going around in circles, trying to move onto to something else but can't until I sort this! When I open the pause menu the player can still interact with other menus that may have been opened before the pause menu was opened.

This obviously is not ideal, I've tried various methods but nothing has helped. I must explain that my game can be controlled in two ways, either Mouse or Keyboard/Controller. If in mouse then all the menus are navigated by the mouse and the issue I encounter is easily avoidable as I inserted a a panel that fills the screen so that it blocks all raycasts and prevents the player from clicking beyond the pause menu.

My problem comes from when the player is controlling with a Keyboard or Controller, whilst in this control scheme I set all the first selected elements via a custom script to allow for direct navigation of the menus (this works perfectly with no issues) however if I, for example, open the Inventory first and then the pause menu the element of the Inventory is still selected and so not only can the player not get to the pause menu (unless obviously using the mouse) they are also able to click on the Inventory icons.

Quick example is below, you can see that I have opened the pause menu after the Inventory however the shift left button of the inventory is still highlighted and selected and the player is stuck on this menu whilst in Keyboard/Controller method.

I tried running custom scripts however for some reason I can't seem to get what I want working, I have tried going down the route of setting the selected game object of the current event system via the following - EventSystem.current.SetSelectedGameObject (myButton);

The myButton variable is set correctly to the gameobject I want however it doesn't change. I've also set up a custom script that shows what the current selected game object is at any time and this updates correctly when I open a menu on it's own as AC sets the FirstSelectedElement correctly and updates the event manager however nothing changes when I open a second menu with the first still being active and open.

Any advice? Or do I need to close all menus whenever I open a second menu? Seems taxing particular considering I don't see a universal close all menus option in the action lists and would have to close each one (and then even more taxing would be to find out which were open originally so that I correctly turn back on the correct ones once I exit the new menu.

Any help would be greatly appreciated, either with setting the first selected game object or even a better alternative that I'm missing entirely. Thanks in advance.


  • Are you using a custom EventSystem, even just one present in the scene file?

    When the Input method is set to Keyboard Or Controller, AC has a built-in way of blocking mouse-clicks - so there's no need to have a raycast-blocking panel.  This is provided, however, that no custom EventSystem is used - and that Disable mouse when keyboard-controlling Unity UI Menus? is checked in the Menu Manager.

    What is the Appear type of the Inventory menu, and does it also pause the game?  It shouldn't be that this occurs in a keyboard/controller-only game, so the first thing will be to get it working correctly (or confirm that it's a problem), without any custom scripts that alter settings based on input.

    I would recommend trying to get the desired behaviour in a separate game (you can use the NGW to create more Managers in the same project, and then share the same Menu Manager), but fixing it at Keyboard Or Controller input.
  • edited October 2017

    EDIT: Still relevant to read my initial post below however I've just tried setting the pause menu to not pause the game and everything works as desired with the selected element changing to the pause menu even if a previous menu is already open. Now whilst I got my issue working obviously having a pause menu not actually pause the game this still isn't a viable solution however at least it has maybe narrowed down the issue to hopefully help with an ultimate solution?

    Sorry I might not have explained well enough, the problem isn't that mouse clicks are being picked up on the Inventory menu once the pause menu is open, it is that the selected element during direct-navigation is stuck on the Inventory menu when the pause menu is opened instead of switching control over to the pause menu. Apologies for the confusion (my mention of the raycast blocking panel was my way of blocking raycasts whilst the game is being controlled by a mouse because without it the player was free to click on the Inventory behind the pause menu) however my issue is whilst in Keyboard or Controller when the player opens the pause menu with the Inventory already open the element selected stays on the Inventory and the player is unable to navigate onto the pause menu (and even if they could navigate onto it I wouldn't want them starting on the Inventory menu anyway).

    The appear type of the Inventory is set to manual (I setup an Active Input that runs an action list that checks a variable 'Inventory Available' and then it either does nothing if unavailable or it turns it off if the menu is visible or on if not visible). All these action lists run in the background and don't pause gameplay and the actual inventory menu doesn't pause gameplay either.

    p.s. no custom event system, I always make sure any created during scene building are deleted before running in play mode so the default event system that AC instantiates at runtime is being used.

    I also quickly setup a new game, I'm still getting the same behaviour in that I can't seem to force the game to select the pause menu elements once that menu is opened if a previous menu is already on.
  • edited October 2017
    It's fine - I knew the raycast blocking was separate, that was just an aside.

    I may have recreated the issue.  If your Inventory menu doesn't pause the game, are you using the Engine: Manage systems Action to allow in-game control?

    Regarding the non-pausing Pause menu: while I'll try to address the original problem, you can still make use of a Pause menu that doesn't actually pause the game by again using the Engine: Manage systems to disable regular interaction and movement.  An additional Character: Move along path Action may also be necessary to command the player to stop moving.
  • @ChrisIceBox

    Duly noted regarding the raycast blocking, thanks for the advice.

    Yes I enable in-game control when opening the Inventory if in Keyboard/Controller. From a previous post I submitted regarding direct navigation of Unity UI this step of enabling in-game control was advised and helped out so yes this is indeed being enabled.

    For now I'll not do anything until you can recreate (again no rush, very low priority at the moment considering no one is actually going to playing this for a long while other than me)! However good to know that worst case I can look into messing around with the pause menu not pausing the game and utilising the Engine: Manage systems actions as a workaround. Thanks again Chris.
  • Recreated.  This is due to the ordering of Menus as listed in the Menu Manager.  It's not a bug as such, but it is my fault for not covering it in the Manual.

    The ordering of Menus has an impact on a few things, such as display order when drawn with AC.  But with Unity UI, the bottom-most Menu takes direct-control priority over ones above it, which is why the Inventory menu retains control even when Pause is enabled.

    To fix this, move your Pause menu below your Inventory (or vice-versa).  There is, however, a true bug in that when Pause is disabled, the Inventory menu won't re-enable.  This shall be addressed, along with a few other bugs related to the "Auto-select first element" option, in the next update.
  • @ChrisIceBox

    Thanks Chris, I've moved my pause menu right to the bottom of all the menus in the manager to make sure (no other menu can open at the same time as another so this should solve everything).

    The bug you refer to though what do you mean when you say the Inventory won't re-enable? I've tested my new situation (all works with my previous issue, thanks) and when I exit the pause menu (so disable it) the Inventory menu is still intractable for me. Now granted it doesn't select an element whilst in direct navigation in Controller mode so I need to look into forcing this element selection again (unless that is what you're referring to?).

    Thanks again Chris.
  • Yes, that was it - v1.60 is out now.
  • edited November 2017

    Firstly thanks again for all your help above and previously. A minor thing I've spotted that didn't seem worth posting a new discussion is regarding transition from pause to options menu. As mentioned above I was having issues with the Inventory menu being interactable when the pause menu is opened after the Inventory is open and active. Testing through the fixes shown above solved everything with that issue however it highlighted a new one. If the Inventory (or any other menu) is open as well as the Pause menu then when you click on the options button and transition to the options menu this seems to turn all current menus off and then brings up the options menu (so it turns of the Inventory in my example). Then obviously when you transition back to the Pause from the Options it turns Options off and Pause on however it no way of knowing that the Inventory should've been turned back on so it stays inactive.

    This causes issues since I change how the game is controlled if the Inventory is open so if you resume the game from here the game is in 'Inventory control' but with no Inventory menu actually shown. I solved it all simply by changing the Option button function in the Menu Manager, instead of it using the AC click type of Crossfade I told it to run an Action List so that I could simply just turn the Pause off and the Options on. I then changed the same thing for the Back button inside the Options menu. I believe that the Crossfade click type simply turns off all menus and then opens the one that you specify it to crossfade to? 

    As stated I solved this and don't believe it to be a bug per se since I believe that is the way the click type crossfade is designed to work however on the off chance that it isn't then I thought it prudent to bring up. Thanks again Chris.
  • No, that's as intended - and you've solved it correctly.  The "Crossfade" option is basically a convenience tool - and whenever something more custom is required, an ActionList to manually turn on/off the relevent Menus should be used.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.