MenuSystem: new menu disables prefab instead of instance in the scene.

Issue #210 resolved
Phillip Zhang created an issue

When opening a new menu with Disable Menus Underneath on, the new menu will disable the prefab of the previous menu instead of its instance in the scene.

This only happens to the first menu, like the start menu, other menus behave correctly.

How to recreate:

1.Set up two menus with MenuSystem.

2.Open the first menu on startup.

3.Open the second menu with Disable Menus Underneath on, using a button on the first menu.

4.You will see that the prefab of the first menu is disabled, but the instance in the scene is still active.

Comments (11)

  1. Simon Jackson

    That is really odd and seems to be a Unity bug. None of the code touches the prefabs once instantiated.

  2. Phillip Zhang reporter

    I took a look at the script and I think this is happening because of the code in MenuManager.cs line 26: OpenMenu(MenuScreens[StartScreen]); MenuScreens[] is an array referencing the menus' prefabs, and you pushed the start menu's prefab to the menuStack using the OpenMenu() function, instead, we need to push the instance created by CreateInstance() to the menuStack.

  3. DotMeini

    Crossing my fingers for success! :D I tried to take a look at it as well but could not figure it out...

  4. Simon Jackson

    Resolves #210

    Fixed issue where the original script made an incorrect assumption about the association between a prefab and a script. Menu now stacks the gameObject prefabs instead of the prefabs themselves.

    → <<cset 75bcf05f32bc>>

  5. Simon Jackson

    Fixed in source if you want to test. *Note, removed searching for Menu by Type as it was broken. Menu's are only managed by name now. (which was the default)

  6. Log in to comment