Forum rules - please read before posting.

Checking if any menu is visible

I have all narration displayed in a designated Menu (when speech plays, narration only).

Whenever this window closes, I'd like the controls to change depending on whether there is another menu visible that the game turns to, or if it turns back to standard gameplay.

At the moment I have an ever-expanding list of separate is-menu-visible-checks to do this, but I wonder if I could handle it more elegantly. I realize I'd need to script this, since even if I could use something like "check if any menu is visible" this would also include the narration menu that I'm just closing (I suppose).

Ideas?

Comments

  • edited October 2023

    You can check if a given Menu is currently on with:

    AC.PlayerMenus.GetMenuWithName ("MyMenu").IsOn ()
    

    To iterate through all Menus (excluding Narration):

    bool AreAnyMenusOn ()
    {
        foreach (Menu menu in PlayerMenus.GetMenus (true))
        {
            if (menu.title != "Narration" && menu.IsOn ()) return true;
        }
        return false;
    }
    

    To make such a check only when your narration menu is turned off, hook into the OnMenuTurnOff custom event:

    void OnMenuTurnOff (Menu menu, bool isInstant)
    {
        if (menu.title == "Narration")
        {
            //
        }
    }
    

    Alternatively, if you want to run code when re-entering gameplay, you can hook into the OnEnterGameState event.

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.