Files
test/Assets/PerfectWorld/Scripts/Common/DebugRegistry.cs
2025-12-24 18:05:54 +07:00

50 lines
1.2 KiB
C#

#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
namespace BrewMonster
{
public static class DebugRegistry
{
private static readonly HashSet<object> targets = new HashSet<object>();
static DebugRegistry()
{
EditorApplication.playModeStateChanged += OnPlayModeChanged;
}
private static void OnPlayModeChanged(PlayModeStateChange state)
{
if (state == PlayModeStateChange.ExitingEditMode ||
state == PlayModeStateChange.EnteredPlayMode ||
state == PlayModeStateChange.EnteredEditMode)
{
Clear();
UnityEngine.Debug.Log("[DebugRegistry] Cleared");
}
}
public static void Enable(object o)
{
if (o == null) return;
targets.Add(o);
}
public static void Disable(object o)
{
if (o == null) return;
targets.Remove(o);
}
public static bool IsEnabled(object o)
{
return o != null && targets.Contains(o);
}
public static void Clear()
{
targets.Clear();
}
}
}
#endif