从不同场景加载特定的UI菜单

问题描述 投票:0回答:1

您如何从游戏中的“暂停菜单”访问“选项/设置菜单?

我了解在单击按钮时加载不同的场景,但是(通过loadcene)加载的场景随主菜单UI一起打开。加载主菜单场景时,我想加载“选项/设置” UI。我认为只加载Main Menu场景,然后停用Main Menu UI gameObject并激活Options / Settings UI gameObject就足够了,但是它仅在场景更改时加载Main Menu UI。

这是我的按钮单击代码(用于加载选项/设置菜单UI):


    public enum GameOverStates
    {
        Main,
        Store,
    };

    public GameOverStates currentState;

    public GameObject mainMenu;
    public GameObject storeMenu;


    void Update()
    {
        switch (currentState)
        {
            case GameOverStates.Store:

                mainMenu.SetActive(false);
                storeMenu.SetActive(true);

                break;
        }
    }


       // Switch to Store Menu
    public void OnStore()
    {
        UnityEngine.Debug.Log("The fucking store");

        //Change menu state
        Loader.Load(Loader.Scene.MainMenu);
        currentState = GameOverStates.Store;

        ////Play sound effect
        SoundManager.PlaySound(SoundManager.Sound.ButtonClick);
    }

感谢您的帮助:)

c# unity3d settings options
1个回答
0
投票

  1. 您可以使用DontDestroyOnLoad将主菜单保留在任何其他场景中。只需在Start函数上调用它,MainMenu对象就不会被SceneManager破坏。 (Read here
  2. 使用SceneManager.MergeScenes在加载新场景时追加两个不同的场景。因此它将保留您的主菜单并向其中添加其他场景。 (Read Here
© www.soinside.com 2019 - 2024. All rights reserved.