using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class SceneManagement : Singleton { //Get the Scene Transition Name string used in other scripts public string SceneTransitionName { get; private set; } /// /// This method Sets the transition name. /// /// public void SetTransitionName(string sceneTransitionName) { this.SceneTransitionName = sceneTransitionName; } /// /// This method runs as this C# Script is enabled /// and it subscribes to the sceneLoaded event. /// private void OnEnable() { //Subscribe to the sceneLoaded event SceneManager.sceneLoaded += OnSceneLoaded; } /// /// This method runs as this C# Script is disabled and /// it unsubscribes from the sceneLoaded event. /// private void OnDisable() { //Unsubscribe from the sceneLoaded event SceneManager.sceneLoaded -= OnSceneLoaded; } /// /// This method runs when the Scene is loaded and /// it finds the location of the player and display /// it to the player using the location text in Unity. /// /// /// private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //Find the PlayerLocationDisplay component and update the location text PlayerLocationDisplay locationDisplay = FindObjectOfType(); if (locationDisplay != null) { locationDisplay.UpdateLocationText(); } } }