The inspector of the single debug game object in the Unity scene will look something like this:
And the script is as simple as this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EPDebug : MonoBehaviour {
public bool toggle1;
public bool toggle2;
public bool option1;
public bool option2;
public bool option3;
[HideInInspector] public static EPDebug instance;
public void Awake() {
instance = this;
}
public void Start () {
}
public void Update () {
base.Update();
if (toggle1) {
// do stuff each frame
// other game objects can check this variable too
}
if (toggle2) {
// do stuff each frame
// other game objects can check this variable too
}
if (option1) {
// do something once
option1 = false;
}
if (option2) {
// do something once
option2 = false;
}
if (option3) {
// do something once
option3 = false;
}
}
}
I have a toggle that has the game print out verbose information regarding game states and whatever information suits me. I use the button options for creating spontaneous game objects and invoking commands like giving some in-game currency. This debug menu can be extended with number fields to change global variables too.
No comments:
Post a Comment