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

Commit 41f0314

Browse files
Added 'Enable Debug' toggle on events
1 parent f2033e2 commit 41f0314

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public abstract class BaseGameEventListenerEditor : Editor
1010
private SerializedProperty _event;
1111
private SerializedProperty _debugColor;
1212
private SerializedProperty _response;
13+
private SerializedProperty _enableDebug;
1314

1415
protected abstract void DrawRaiseButton();
1516

@@ -21,9 +22,12 @@ protected virtual void OnEnable()
2122
_event = serializedObject.FindProperty("_event");
2223
_debugColor = serializedObject.FindProperty("_debugColor");
2324
_response = serializedObject.FindProperty("_response");
25+
_enableDebug = serializedObject.FindProperty("_enableDebug");
2426
}
2527
public override void OnInspectorGUI()
2628
{
29+
EditorGUILayout.PropertyField(_enableDebug);
30+
2731
EditorGUILayout.ObjectField(_event, new GUIContent("Event", "Event which will trigger the response"));
2832
_debugColor.colorValue = EditorGUILayout.ColorField(new GUIContent("Debug Color", "Color used to draw debug gizmos in the scene"), _debugColor.colorValue);
2933

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ private void OnDisable()
8484
public abstract class DebuggableGameEventListener : SOArchitectureBaseMonobehaviour, IStackTraceObject
8585
{
8686
#if UNITY_EDITOR
87+
[SerializeField]
88+
private bool _enableDebug = true;
8789
[SerializeField]
8890
private Color _debugColor = Color.cyan;
8991
#endif
@@ -186,12 +188,18 @@ private void DrawEvent(int index)
186188
}
187189
private void DrawText(Vector3 position, DebugEvent debugEvent)
188190
{
191+
if (!_enableDebug)
192+
return;
193+
189194
string text = string.Join("\n", new string[] { GameEvent.name, debugEvent.FunctionName });
190195

191196
Handles.Label(position, text, Styles.TextStyle);
192197
}
193198
private void DrawLine()
194199
{
200+
if (!_enableDebug)
201+
return;
202+
195203
List<GameObject> listeningObjects = new List<GameObject>();
196204

197205
for (int i = 0; i < Response.GetPersistentEventCount(); i++)
@@ -209,7 +217,8 @@ private void DrawLine()
209217
}
210218
private void DrawPoint(Vector3 position, Vector3 direction)
211219
{
212-
Handles.DrawAAPolyLine(DOT_WIDTH, position, position + (direction.normalized * DOT_LENGTH));
220+
if(_enableDebug)
221+
Handles.DrawAAPolyLine(DOT_WIDTH, position, position + (direction.normalized * DOT_LENGTH));
213222
}
214223
private void AddObject(List<GameObject> listeningObjects, Object obj)
215224
{

0 commit comments

Comments
 (0)