예제 #1
0
 public static void LoadScene(MySceneInfo sceneInfo)
 {
     if (sceneInfo == null)
     {
         Debug.Log("SceneInfo is null");
         return;
     }
     if (sceneInfo is MainSceneInfo msi)
     {
         LoadMainScene(msi);
     }
     else if (sceneInfo is AdditiveSceneInfo asi)
     {
         LoadAdditiveScene(asi);
     }
 }
예제 #2
0
        private static void OnLoadSceneCompleted(MySceneInfo sceneInfo)
        {
            if (TryGetActiveScene(sceneInfo, out Scene scene))
            {
                SceneDataRepository.LoadData(scene);
                loadedScenesInLevel.Add(scene.buildIndex);

                if (sceneInfo is MainSceneInfo mainSceneInfo && mainSceneInfo.StartCheckpoint != null)
                {
                    CheckpointManager.SetStartCheckpoint(mainSceneInfo.StartCheckpoint);
                }
            }
            else
            {
                Debug.LogError("Something went wrong when loading scene");
            }
        }
예제 #3
0
        public static void UnloadScene(MySceneInfo sceneInfo)
        {
            if (sceneInfo == null)
            {
                Debug.Log("SceneInfo is null");
                return;
            }

            if (TryGetActiveScene(sceneInfo, out Scene scene))
            {
                SceneDataRepository.SaveData(scene);
                GetUnload(scene);
            }
            else
            {
                Debug.Log("Scene " + sceneInfo.name + " was not loaded");
            }
        }
예제 #4
0
 private static bool TryGetActiveScene(MySceneInfo sceneInfo, out Scene scene)
 {
     scene = SceneManager.GetSceneByPath(sceneInfo.ScenePath);
     return(scene != null && scene.isLoaded);
 }
예제 #5
0
 private static AsyncOperation GetLoad(MySceneInfo sceneInfo, LoadSceneMode loadMode)
 {
     return(SceneManager.LoadSceneAsync(sceneInfo.ScenePath, loadMode));
 }