diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index e4b670e2..60bfd4a5 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -14,8 +14,10 @@ using QSB.StatueSync; using QSB.TimeSync; using QSB.Utility; using QSB.WorldSync; +using System; using System.Linq; using UnityEngine; +using UnityEngine.InputSystem; /* Copyright (C) 2020 - 2021 @@ -150,14 +152,20 @@ namespace QSB } } - public static void ToggleDebug() + private void Update() { - DebugSettings.DebugMode = !DebugSettings.DebugMode; + if (Keyboard.current[Key.Q].isPressed && Keyboard.current[Key.D].isPressed && + (Keyboard.current[Key.Q].wasPressedThisFrame || Keyboard.current[Key.D].wasPressedThisFrame)) + { + DebugSettings.DebugMode = !DebugSettings.DebugMode; - QuantumManager.UpdateFromDebugSetting(); - DebugCameraSettings.UpdateFromDebugSetting(); + GetComponent().enabled = DebugMode; + GetComponent().enabled = DebugMode; + QuantumManager.UpdateFromDebugSetting(); + DebugCameraSettings.UpdateFromDebugSetting(); - DebugLog.ToConsole($"DEBUG MODE = {DebugMode}"); + DebugLog.ToConsole($"DEBUG MODE = {DebugMode}"); + } } } } diff --git a/QSB/Utility/DebugActions.cs b/QSB/Utility/DebugActions.cs index 8466e55f..3dfbe160 100644 --- a/QSB/Utility/DebugActions.cs +++ b/QSB/Utility/DebugActions.cs @@ -2,6 +2,7 @@ using QSB.Player; using QSB.ShipSync; using QSB.Utility.Messages; +using System; using System.Linq; using UnityEngine; using UnityEngine.InputSystem; @@ -31,18 +32,10 @@ namespace QSB.Utility private void DamageShipElectricalSystem() => ShipManager.Instance.ShipElectricalComponent.SetDamaged(true); + private void Awake() => enabled = QSBCore.DebugMode; + public void Update() { - if (Keyboard.current[Key.Q].isPressed && Keyboard.current[Key.D].wasPressedThisFrame) - { - QSBCore.ToggleDebug(); - } - - if (!QSBCore.DebugMode) - { - return; - } - /* * 1 - Warp to first non local player * 2 - Set time flowing diff --git a/QSB/Utility/DebugGUI.cs b/QSB/Utility/DebugGUI.cs index 490e9c6e..b8ed780d 100644 --- a/QSB/Utility/DebugGUI.cs +++ b/QSB/Utility/DebugGUI.cs @@ -30,7 +30,12 @@ namespace QSB.Utility private readonly GUIStyle guiGUIStyle = new(); private static readonly GUIStyle labelGUIStyle = new(); - private void Awake() => guiGUIStyle.fontSize = 9; + private void Awake() + { + enabled = QSBCore.DebugMode; + + guiGUIStyle.fontSize = 9; + } private void WriteLine(int columnID, string text) { @@ -72,8 +77,7 @@ namespace QSB.Utility public void OnGUI() { - if (!QSBCore.DebugMode || - Event.current.type != EventType.Repaint) + if (Event.current.type != EventType.Repaint) { return; }