Strip UI debug stuff from the game

This commit is contained in:
Michal Pikulski
2025-10-17 14:44:03 +02:00
parent d8653762f4
commit 09af055d18
3 changed files with 19 additions and 30 deletions

View File

@@ -1,6 +1,8 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using AppleHills.Core.Settings;
using Core;
public class DebugUIMessage : MonoBehaviour
{
@@ -17,6 +19,14 @@ public class DebugUIMessage : MonoBehaviour
/// <param name="displayColor"></param>
public static void Show(string message, Color displayColor, float duration = 2f)
{
#if UNITY_EDITOR
var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>();
if (divingDevSettings && !divingDevSettings.ShowDebugUiMessages)
{
Logging.Debug($"[DebugUIMessage] Loggig debug message: {message}");
return;
}
if (instance == null)
{
var go = new GameObject("DebugUIMessage");
@@ -25,6 +35,9 @@ public class DebugUIMessage : MonoBehaviour
DontDestroyOnLoad(go);
}
instance.ShowMessage(message, duration, displayColor);
# else
Logging.Debug($"[DebugUIMessage] Loggig debug message: {message}");
#endif
}
/// <summary>

View File

@@ -21,31 +21,12 @@ namespace AppleHills.Core.Settings
[CreateAssetMenu(fileName = "DebugSettings", menuName = "AppleHills/Developer Settings/Debug", order = 2)]
public class DebugSettings : BaseDeveloperSettings
{
[Header("Visualization")]
[Tooltip("Show colliders for game objects")]
[SerializeField] private bool showColliders = false;
[Tooltip("Show performance statistics (FPS, memory usage, etc.)")]
[SerializeField] private bool showPerformanceStats = false;
[Header("Logging")]
[Tooltip("Level of detail for logging")]
[SerializeField] private LogVerbosity logLevel = LogVerbosity.Warnings;
[Header("Gameplay")]
[Tooltip("Make player invulnerable and ignore gameplay restrictions")]
[SerializeField] private bool godMode = false;
[Tooltip("Global time scale for debugging animations and effects")]
[Range(0.1f, 10f)]
[SerializeField] private float timeScale = 1.0f;
[Header("Visual Debugging Options")]
[Tooltip("Should debug messages be show on screen in Editor")]
[SerializeField] private bool showDebugUiMessages = false;
// Property getters
public bool ShowColliders => showColliders;
public bool ShowPerformanceStats => showPerformanceStats;
public LogVerbosity LogLevel => logLevel;
public bool GodMode => godMode;
public float TimeScale => timeScale;
public bool ShowDebugUiMessages => showDebugUiMessages;
public override void OnValidate()
{
@@ -54,8 +35,7 @@ namespace AppleHills.Core.Settings
// Apply any immediate effects when values change in the editor
if (Application.isPlaying)
{
// Set time scale directly when changed in editor
Time.timeScale = timeScale;
}
}
}

View File

@@ -12,8 +12,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d9fd485d4ab84bea9946425e742ccd9c, type: 3}
m_Name: DebugSettings
m_EditorClassIdentifier: AppleHillsScripts::AppleHills.Core.Settings.DebugSettings
showColliders: 0
showPerformanceStats: 0
logLevel: 2
godMode: 0
timeScale: 7.09
showDebugUiMessages: 1