GetSceneAt() public static method

Get the scene at index in the SceneManager's list of added scenes.

public static GetSceneAt ( int index ) : Scene
index int Index of the scene to get. Index must be greater than or equal to 0 and less than SceneManager.sceneCount.
return Scene
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_SceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (m_SceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            m_SceneManager.LoadSceneSuccess         += OnLoadSceneSuccess;
            m_SceneManager.LoadSceneFailure         += OnLoadSceneFailure;
            m_SceneManager.LoadSceneUpdate          += OnLoadSceneUpdate;
            m_SceneManager.LoadSceneDependencyAsset += OnLoadSceneDependencyAsset;
            m_SceneManager.UnloadSceneSuccess       += OnUnloadSceneSuccess;
            m_SceneManager.UnloadSceneFailure       += OnUnloadSceneFailure;

            m_GameFrameworkScene = SceneManager.GetSceneAt(GameEntry.GameFrameworkSceneId);
            if (!m_GameFrameworkScene.IsValid())
            {
                Log.Fatal("Game Framework scene is invalid.");
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Tries to get the given index's scene
        /// </summary>
        public static bool TryGetSceneAt(int index, out Scene scene)
        {
            if (!SceneExists(index))
            {
                scene = default;
                return(false);
            }

            scene = SM.GetSceneAt(index);
            return(true);
        }
Exemplo n.º 3
0
    /* Make sure this scene is unique, since the loader will actually load it
     * when in-game */
    private System.Collections.IEnumerator makeSceneUnique()
    {
        Scene[] scenes;
        AsyncOp op;
        int     mainIdx;

        scenes  = new Scene[SceneMng.sceneCount];
        mainIdx = -1;
        for (int i = 0; i < scenes.Length; i++)
        {
            scenes[i] = SceneMng.GetSceneAt(i);
            if (scenes[i].name == this.GameOverSceneName)
            {
                mainIdx = i;
            }
        }
        if (mainIdx == -1)
        {
            throw new System.Exception($"Didn't find the expected scene ({this.GameOverSceneName})");
        }

        for (int i = 0; i < scenes.Length; i++)
        {
            if (i == mainIdx)
            {
                continue;
            }
            op = SceneMng.UnloadSceneAsync(scenes[i]);
            yield return(op);
        }

        SceneMng.SetActiveScene(scenes[mainIdx]);
        yield return(SceneMng.LoadSceneAsync(
                         "scenes/000-game-controller/bg-scenes/GameOverBG",
                         SceneMode.Additive));

        yield return(runGameOverAnim());
    }
Exemplo n.º 4
0
 public static Scene LoadScene(int sceneBuildIndex, LoadSceneParameters parameters)
 {
     SceneManager.LoadSceneAsyncNameIndexInternal(null, sceneBuildIndex, parameters, true);
     return(SceneManager.GetSceneAt(SceneManager.sceneCount - 1));
 }
Exemplo n.º 5
0
 public static Scene LoadScene(string sceneName, LoadSceneParameters parameters)
 {
     SceneManager.LoadSceneAsyncNameIndexInternal(sceneName, -1, parameters, true);
     return(SceneManager.GetSceneAt(SceneManager.sceneCount - 1));
 }