From 33ee9e08e1ed7ca2f4213d5dbe70a46335e43082 Mon Sep 17 00:00:00 2001 From: slevy14 Date: Wed, 26 Apr 2023 13:27:08 -0700 Subject: [PATCH] added a debug mode variable to state controller if this is checked, then the debug menu will be useable. when building the game, make sure to uncheck the debug mode box to prevent it from coming up in the build --- Assets/Scenes/MainMenu.unity | 1 + Assets/Scripts/DebugSceneSwitcher.cs | 3 +++ Assets/Scripts/StateController.cs | 12 +++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index 1e8f25c..f3f6f8a 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -2400,6 +2400,7 @@ MonoBehaviour: deathCanvas: {fileID: 0} isPaused: 0 pauseMenuCanvas: {fileID: 0} + inDebugMode: 1 --- !u!114 &2038492347 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/DebugSceneSwitcher.cs b/Assets/Scripts/DebugSceneSwitcher.cs index 81541c8..9b7eb19 100644 --- a/Assets/Scripts/DebugSceneSwitcher.cs +++ b/Assets/Scripts/DebugSceneSwitcher.cs @@ -8,6 +8,9 @@ public class DebugSceneSwitcher : MonoBehaviour { void Awake() { + if (!GameObject.Find("StateController").GetComponent().inDebugMode) { + Destroy(this.gameObject); + } // check to see if a debug canvas already exists if (GameObject.FindGameObjectWithTag("DebugCanvas") != null) { Destroy(this.gameObject); diff --git a/Assets/Scripts/StateController.cs b/Assets/Scripts/StateController.cs index 423081e..4688a06 100644 --- a/Assets/Scripts/StateController.cs +++ b/Assets/Scripts/StateController.cs @@ -15,6 +15,8 @@ public class StateController : MonoBehaviour { public bool isPaused = false; public GameObject pauseMenuCanvas; + [Header("Debug")] + public bool inDebugMode; GameObject debugCanvas; void Awake() { @@ -27,8 +29,10 @@ public class StateController : MonoBehaviour { DontDestroyOnLoad(this.gameObject); SceneManager.sceneLoaded += OnSceneLoaded; - debugCanvas = GameObject.Find("DebugCanvas"); - debugCanvas.SetActive(false); + if (inDebugMode) { + debugCanvas = GameObject.Find("DebugCanvas"); + debugCanvas.SetActive(false); + } } void OnSceneLoaded(Scene scene, LoadSceneMode mode) { @@ -52,7 +56,9 @@ public class StateController : MonoBehaviour { } void OnToggleDebugMenu() { - debugCanvas.SetActive(!debugCanvas.activeSelf); + if (inDebugMode) { + debugCanvas.SetActive(!debugCanvas.activeSelf); + } } void OnPause() {