2using System.Collections;
4using UnityEngine.SceneManagement;
26 private IEnumerator
Fade(
float finalAlpha )
32 m_FaderCanvasGroup.blocksRaycasts =
true;
41 m_FaderCanvasGroup.alpha = Mathf.MoveTowards(
m_FaderCanvasGroup.alpha, finalAlpha, fadeSpeed * Time.deltaTime );
51 m_FaderCanvasGroup.blocksRaycasts =
false;
66 yield
return StartCoroutine(
Fade( 1.0f ) );
72 Player.Instance.gameObject.transform.position = spawnPosition;
78 yield
return SceneManager.UnloadSceneAsync( SceneManager.GetActiveScene().buildIndex );
90 yield
return StartCoroutine(
Fade(0.0f) );
105 yield
return SceneManager.LoadSceneAsync( sceneName, LoadSceneMode.Additive );
108 Scene newlyLoadedScene = SceneManager.GetSceneAt( SceneManager.sceneCount - 1 );
111 SceneManager.SetActiveScene( newlyLoadedScene );
121 m_FaderImage.color =
new Color( 0f, 0f, 0f, 1f );
122 m_FaderCanvasGroup.alpha = 1f;
134 StartCoroutine(
Fade( 0f ) );
SceneName
Describes different scenes.
Raise an handle event when a movement is triggered.
static void CallAfterSceneLoadEvent()
Call after scene load event
static void CallBeforeSceneUnloadEvent()
Call before scene unload event
static void CallBeforeSceneUnloadFadeOutEvent()
Call before scene unload, fade out event
static void CallAfterSceneLoadFadeInEvent()
Call after scene load fade in event
Manage saving and loading scenes. This class is a singleton instance.
Manage the transition between scenes
void FadeAndLoadScene(string sceneName, Vector3 spawnPosition)
This is the main externam point of contact and influence from the rest of the project....
SceneName m_StartingSceneName
IEnumerator Fade(float finalAlpha)
Handle the fade in blocking and unblocking inputs.
IEnumerator Start()
Load the starting scene
IEnumerator LoadSceneAndSetActive(string sceneName)
Load the scene and the activate it. Basically, we are additing our new scene to the Persistent scene.
CanvasGroup m_FaderCanvasGroup
IEnumerator FadeAndSwitchScenes(string sceneName, Vector3 spawnPosition)
Handle fading, switching and unloading scenes.
Abstract class that inherited by all the game managers. All the game managers use singleton since gam...