Forum rules - please read before posting.

Locking/unlocking menus via code

Hi, community! I'm trying to lock and unlock a menu in C#, and I'm struggling a bit with syntax. Does anyone have suggestions!

Right now, to use the isLocked property of my menu, I assume I need to refer to that specific menu.

So right now I'm trying this:
private readonly Menu LOADMENU_NAME = MenuManager.GetMenuWithName("InGame Menu");

but I'm getting this error:
"An object reference is required for the non-static field, method, or property"

So I'm assuming I need to get the current active MenuManager, or instantiate it, but I don't see a method for that in the MenuManager class definition.

Any advice?

Comments

  • You can't declare the value of a menu outside of a function, because the menu itself only exists at runtime.

    It's also the case that runtime Menus are stored in PlayerMenus. MenuManager is used to store the original Menu data, but these are copied to PlayerMenus for runtime modification.

    Inside a function, you can use:

    Menu myMenu = MenuManager.GetMenuWithName("InGame Menu");
    myMenu.isLocked = true;
    

    See the Manual's "Menu scripting" chapter for a general overview to working with menus in custom scripts.

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.