Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit d8b9ff6

Browse files
Improved game event listener inspector
1 parent 41f0314 commit d8b9ff6

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

Assets/SO Architecture/Editor/Inspectors/BaseGameEventListenerEditor.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public abstract class BaseGameEventListenerEditor : Editor
1111
private SerializedProperty _debugColor;
1212
private SerializedProperty _response;
1313
private SerializedProperty _enableDebug;
14+
private SerializedProperty _showDebugFields;
1415

1516
protected abstract void DrawRaiseButton();
1617

@@ -22,23 +23,51 @@ protected virtual void OnEnable()
2223
_event = serializedObject.FindProperty("_event");
2324
_debugColor = serializedObject.FindProperty("_debugColor");
2425
_response = serializedObject.FindProperty("_response");
25-
_enableDebug = serializedObject.FindProperty("_enableDebug");
26+
_enableDebug = serializedObject.FindProperty("_enableGizmoDebugging");
27+
_showDebugFields = serializedObject.FindProperty("_showDebugFields");
2628
}
2729
public override void OnInspectorGUI()
2830
{
29-
EditorGUILayout.PropertyField(_enableDebug);
30-
3131
EditorGUILayout.ObjectField(_event, new GUIContent("Event", "Event which will trigger the response"));
32-
_debugColor.colorValue = EditorGUILayout.ColorField(new GUIContent("Debug Color", "Color used to draw debug gizmos in the scene"), _debugColor.colorValue);
33-
3432
EditorGUILayout.PropertyField(_response, new GUIContent("Response"));
35-
36-
DrawRaiseButton();
37-
38-
_stackTrace.Draw();
3933

34+
_showDebugFields.boolValue = EditorGUILayout.Foldout(_showDebugFields.boolValue, new GUIContent("Show Debug Fields"));
35+
if (_showDebugFields.boolValue)
36+
{
37+
DrawDebugging();
38+
}
39+
4040
EditorGUILayout.PropertyField(DeveloperDescription);
4141

4242
serializedObject.ApplyModifiedProperties();
4343
}
44+
private void DrawDebugging()
45+
{
46+
EditorGUILayout.LabelField("Callback Debugging", EditorStyles.boldLabel);
47+
using (new EditorGUI.IndentLevelScope())
48+
{
49+
DrawRaiseButton();
50+
51+
_stackTrace.Draw();
52+
}
53+
54+
55+
EditorGUILayout.Space();
56+
EditorGUILayout.Space();
57+
58+
59+
EditorGUILayout.LabelField("Gizmo Debugging", EditorStyles.boldLabel);
60+
using (new EditorGUI.IndentLevelScope())
61+
{
62+
EditorGUILayout.PropertyField(_enableDebug, new GUIContent("Enable Gizmo Debugging"));
63+
64+
using (new EditorGUI.DisabledGroupScope(_enableDebug.boolValue))
65+
{
66+
EditorGUILayout.PropertyField(_debugColor, new GUIContent("Debug Color", "Color used to draw debug gizmos in the scene"));
67+
}
68+
}
69+
70+
71+
EditorGUILayout.Space();
72+
}
4473
}

Assets/SO Architecture/Events/Listeners/BaseGameEventListener.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public abstract class DebuggableGameEventListener : SOArchitectureBaseMonobehavi
8585
{
8686
#if UNITY_EDITOR
8787
[SerializeField]
88-
private bool _enableDebug = true;
88+
private bool _showDebugFields = false;
89+
[SerializeField]
90+
private bool _enableGizmoDebugging = true;
8991
[SerializeField]
9092
private Color _debugColor = Color.cyan;
9193
#endif
@@ -188,7 +190,7 @@ private void DrawEvent(int index)
188190
}
189191
private void DrawText(Vector3 position, DebugEvent debugEvent)
190192
{
191-
if (!_enableDebug)
193+
if (!_enableGizmoDebugging)
192194
return;
193195

194196
string text = string.Join("\n", new string[] { GameEvent.name, debugEvent.FunctionName });
@@ -197,7 +199,7 @@ private void DrawText(Vector3 position, DebugEvent debugEvent)
197199
}
198200
private void DrawLine()
199201
{
200-
if (!_enableDebug)
202+
if (!_enableGizmoDebugging)
201203
return;
202204

203205
List<GameObject> listeningObjects = new List<GameObject>();
@@ -217,7 +219,7 @@ private void DrawLine()
217219
}
218220
private void DrawPoint(Vector3 position, Vector3 direction)
219221
{
220-
if(_enableDebug)
222+
if(_enableGizmoDebugging)
221223
Handles.DrawAAPolyLine(DOT_WIDTH, position, position + (direction.normalized * DOT_LENGTH));
222224
}
223225
private void AddObject(List<GameObject> listeningObjects, Object obj)

0 commit comments

Comments
 (0)