48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
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();
|
|
}
|
|
}
|
|
|
|
}
|