debug
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
public static class ComponentDebugMenu
|
||||
{
|
||||
[MenuItem("CONTEXT/MonoBehaviour/Enable Debug")]
|
||||
static void EnableDebug(MenuCommand command)
|
||||
{
|
||||
var comp = command.context as MonoBehaviour;
|
||||
DebugRegistry.Enable(comp);
|
||||
Debug.Log($"Debug enabled: {comp.name} ({comp.GetType().Name})");
|
||||
}
|
||||
|
||||
[MenuItem("CONTEXT/MonoBehaviour/Disable Debug")]
|
||||
static void DisableDebug(MenuCommand command)
|
||||
{
|
||||
var comp = command.context as MonoBehaviour;
|
||||
DebugRegistry.Disable(comp);
|
||||
Debug.Log($"Debug disabled: {comp.name} ({comp.GetType().Name})");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6b200e61208f0f4bb396ec3aa442feb
|
||||
@@ -0,0 +1,56 @@
|
||||
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}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6647e1ce7626a94194f2100e8500343
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
[CustomEditor(typeof(MonoBehaviour), true)]
|
||||
public class DebuggableInspector : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var targetMb = target as MonoBehaviour;
|
||||
|
||||
if (targetMb != null && DebugRegistry.IsEnabled(targetMb))
|
||||
{
|
||||
GUI.backgroundColor = Color.yellow;
|
||||
EditorGUILayout.HelpBox("DEBUG ENABLED", MessageType.Info);
|
||||
GUI.backgroundColor = Color.white;
|
||||
}
|
||||
|
||||
DrawDefaultInspector();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1fca6a9b0c2bb3408095b0d47723f55
|
||||
Reference in New Issue
Block a user