public void LoadScene(ScenesToLoad nextScene) { //if (audio.isPlaying) //{ // audio.Stop(); //} currentLevel = (int)nextScene; SceneManager.LoadScene((int)nextScene); }
/// <summary> /// Loads a new scene with a fade to black transition effect. /// </summary> /// <param name="oldScene">The scene to unload.</param> /// <param name="destination">The UniqueID of a destination UniqueComponent.</param> /// <param name="player">The player's GameObject.</param> public void FadeScenes() { if (CurrentlyLoading) { CurrentlyLoadingSceneError(); } if ((ScenesToLoad == null || ScenesToLoad.Count == 0) && Destination == null) { NoSceneToLoadError(); } if (Destination != null) { if (ScenesToLoad == null) { ScenesToLoad = new List <string>(); ScenesToLoad.Add(Destination.SceneName); } else if (!ScenesToLoad.Contains(Destination.SceneName)) { ScenesToLoad.Add(Destination.SceneName); } } runningWithoutSceneLoader = false; foreach (var scene in ScenesToUnload) { OnSceneAboutToUnload?.Invoke(scene); } //Request loading of loading screen. AsyncOperation loadingSceneLoadOperation = SceneManager.LoadSceneAsync(loadingScene, LoadSceneMode.Additive); //Registers OnLoadingSceneLoaded as listener to complete. loadingSceneLoadOperation.completed += OnLoadingSceneLoaded; }
private IEnumerator LoadGame(ScenesToLoad sceneToload, Action afterSceneLoadingCallback) { yield return(SceneManager.LoadSceneAsync(ScenesPath + ((int)sceneToload).ToString())); afterSceneLoadingCallback(); }
public void StartLoadScene(ScenesToLoad sceneToLoad, Action afterSceneLoadingCallback) { StartCoroutine(LoadGame(sceneToLoad, afterSceneLoadingCallback)); }