57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
public static class DebugRegistryEditor
|
|
{
|
|
[MenuItem("Tools/Debug Registry/Clear All")]
|
|
private static void ClearAll()
|
|
{
|
|
DebugRegistry.Clear();
|
|
Debug.Log("DebugRegistry Cleared");
|
|
}
|
|
|
|
[MenuItem("GameObject/Enable Logging For This Component", true)]
|
|
private static bool ValidateEnableLogging()
|
|
{
|
|
return Selection.activeGameObject != null;
|
|
}
|
|
|
|
[MenuItem("GameObject/Enable Logging For This Component")]
|
|
private static void EnableLogging()
|
|
{
|
|
var go = Selection.activeGameObject;
|
|
if (go == null) return;
|
|
|
|
var comps = go.GetComponents<MonoBehaviour>();
|
|
|
|
Selection.objects = comps; // để hiển thị popup
|
|
|
|
EditorApplication.delayCall += () =>
|
|
{
|
|
foreach (var comp in comps)
|
|
DebugRegistry.Enable(comp);
|
|
Debug.Log($"Enabled logging for all components of {go.name}");
|
|
};
|
|
}
|
|
|
|
[MenuItem("GameObject/Disable Logging For This Component", true)]
|
|
private static bool ValidateDisableLogging()
|
|
{
|
|
return Selection.activeGameObject != null;
|
|
}
|
|
|
|
[MenuItem("GameObject/Disable Logging For This Component")]
|
|
private static void DisableLogging()
|
|
{
|
|
var go = Selection.activeGameObject;
|
|
foreach (var comp in go.GetComponents<MonoBehaviour>())
|
|
DebugRegistry.Disable(comp);
|
|
|
|
Debug.Log($"Disabled logging for all components of {go.name}");
|
|
}
|
|
}
|
|
|
|
}
|