Ejemplo n.º 1
0
 public void LoadScene(ScenesToLoad nextScene)
 {
     //if (audio.isPlaying)
     //{
     //    audio.Stop();
     //}
     currentLevel = (int)nextScene;
     SceneManager.LoadScene((int)nextScene);
 }
Ejemplo n.º 2
0
        /// <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;
        }
Ejemplo n.º 3
0
    private IEnumerator LoadGame(ScenesToLoad sceneToload, Action afterSceneLoadingCallback)
    {
        yield return(SceneManager.LoadSceneAsync(ScenesPath + ((int)sceneToload).ToString()));

        afterSceneLoadingCallback();
    }
Ejemplo n.º 4
0
 public void StartLoadScene(ScenesToLoad sceneToLoad, Action afterSceneLoadingCallback)
 {
     StartCoroutine(LoadGame(sceneToLoad, afterSceneLoadingCallback));
 }