예제 #1
0
    /// <summary>
    /// 将当前场景入栈,并加载新场景
    /// </summary>
    /// <param name="next">待加载的场景</param>
    public void PushScene(SceneBase next)
    {
        if (next == null)
        {
            Debug.LogWarning("SceneManager.PushScene : Null GameScene.");
            return;
        }

        if (currentScene != null)
        {
            if (currentScene.SNode == next.SNode)
            {
                Debug.LogWarning("SceneManager.PushScene : The Same GameScene.");
                return;
            }

            currentScene.OnPushed(next);
            sceneStack.AddLast(currentScene);
        }

        next.LoadScene();
        next.UpdateAudioState();
        next.UpdateGlobalLight();
        currentScene = next;
    }
예제 #2
0
    /// <summary>
    /// 弹出栈顶场景,并将当前场景销毁
    /// </summary>
    public void PopScene()
    {
        if (sceneStack.Count <= 0 || sceneStack.Last == null)
        {
            return;
        }

        SceneBase last    = currentScene;
        SceneBase bePoped = sceneStack.Last.Value;

        if (currentScene != null)
        {
            currentScene.OnDestroy();
        }

        if (bePoped != null)
        {
            bePoped.OnPoped(last);

            bePoped.LoadScene();
            bePoped.UpdateAudioState();
            bePoped.UpdateGlobalLight();

            currentScene = bePoped;
        }

        sceneStack.RemoveLast();
    }
예제 #3
0
    /// <summary>
    /// 直接替换当前场景,无出入栈操作
    /// </summary>
    /// <param name="next"></param>
    public void ReplaceScene(SceneBase next)
    {
        if (next == null)
        {
            Debug.LogWarning("SceneManager.ReplaceScene : Null GameScene.");
            return;
        }

        if (currentScene != null)
        {
            currentScene.OnReplaced(next);
            currentScene.OnDestroy();
        }

        next.LoadScene();
        next.UpdateAudioState();
        next.UpdateGlobalLight();
        currentScene = next;
    }