using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class StateController : MonoBehaviour { [Header("Respawning")] [SerializeField] GameObject player; public GameObject spawnPoint; [SerializeField] private GameObject deathCanvas; [Header("Pause Menu")] public bool isPaused = false; public GameObject pauseMenuCanvas; [Header("Debug")] public bool inDebugMode; GameObject debugCanvas; [Header("Enemies")] GameObject[] enemiesInScene; [Header("LevelProgression")] GameObject victoryCanvas; void Awake() { // check to see if a state controller already exists if (GameObject.FindGameObjectWithTag("StateController") != null) { Destroy(this.gameObject); } else { // if it doesn't, then this is the only one this.gameObject.tag = "StateController"; } DontDestroyOnLoad(this.gameObject); SceneManager.sceneLoaded += OnSceneLoaded; if (inDebugMode) { debugCanvas = GameObject.FindGameObjectWithTag("DebugCanvas"); debugCanvas.SetActive(false); } } void OnSceneLoaded(Scene scene, LoadSceneMode mode) { deathCanvas = GameObject.Find("DeathUICanvas"); if (deathCanvas != null) { Button respawnButton = GameObject.Find("RespawnButton").GetComponent