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
This commit is contained in:
slevy14 2023-04-26 13:27:08 -07:00
parent 41d128373d
commit 33ee9e08e1
3 changed files with 13 additions and 3 deletions

View File

@ -2400,6 +2400,7 @@ MonoBehaviour:
deathCanvas: {fileID: 0}
isPaused: 0
pauseMenuCanvas: {fileID: 0}
inDebugMode: 1
--- !u!114 &2038492347
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -8,6 +8,9 @@ public class DebugSceneSwitcher : MonoBehaviour
{
void Awake() {
if (!GameObject.Find("StateController").GetComponent<StateController>().inDebugMode) {
Destroy(this.gameObject);
}
// check to see if a debug canvas already exists
if (GameObject.FindGameObjectWithTag("DebugCanvas") != null) {
Destroy(this.gameObject);

View File

@ -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() {