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); } }
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"); } }
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"); } }
private static bool TryGetActiveScene(MySceneInfo sceneInfo, out Scene scene) { scene = SceneManager.GetSceneByPath(sceneInfo.ScenePath); return(scene != null && scene.isLoaded); }
private static AsyncOperation GetLoad(MySceneInfo sceneInfo, LoadSceneMode loadMode) { return(SceneManager.LoadSceneAsync(sceneInfo.ScenePath, loadMode)); }