diff --git a/Editor/EventManagerEditor.cs b/Editor/EventManagerEditor.cs index ba2c24e..b907d3e 100644 --- a/Editor/EventManagerEditor.cs +++ b/Editor/EventManagerEditor.cs @@ -8,13 +8,13 @@ namespace Utils { public override void OnInspectorGUI() { - EventManager myTarget = (EventManager)target; + EventManager eventManager = (EventManager)target; GUILayout.BeginHorizontal(); GUILayout.Label("Update"); if (Application.isPlaying) { GUILayout.FlexibleSpace(); - GUILayout.Label(myTarget.UpdateLength().ToString()); + GUILayout.Label(eventManager.UpdateLength.ToString()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); @@ -22,7 +22,7 @@ namespace Utils if (Application.isPlaying) { GUILayout.FlexibleSpace(); - GUILayout.Label(myTarget.FixedUpdateLength().ToString()); + GUILayout.Label(eventManager.FixedUpdateLength.ToString()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); @@ -30,7 +30,7 @@ namespace Utils if (Application.isPlaying) { GUILayout.FlexibleSpace(); - GUILayout.Label(myTarget.LateUpdateLength().ToString()); + GUILayout.Label(eventManager.LateUpdateLength.ToString()); } GUILayout.EndHorizontal(); } diff --git a/Runtime/EventManager.cs b/Runtime/EventManager.cs index 315f8d0..78719e6 100644 --- a/Runtime/EventManager.cs +++ b/Runtime/EventManager.cs @@ -28,19 +28,52 @@ namespace Utils OnLateUpdated?.Invoke(); } - public int UpdateLength() + public int UpdateLength { - return (int)OnUpdated?.GetInvocationList().Length; + get + { + var list = OnUpdated?.GetInvocationList(); + if (list != null) + { + return list.Length; + } + else + { + return 0; + } + } } - public int FixedUpdateLength() + public int FixedUpdateLength { - return (int)OnFixedUpdated?.GetInvocationList().Length; + get + { + var list = OnFixedUpdated?.GetInvocationList(); + if (list != null) + { + return list.Length; + } + else + { + return 0; + } + } } - public int LateUpdateLength() + public int LateUpdateLength { - return (int)OnLateUpdated?.GetInvocationList().Length; + get + { + var list = OnLateUpdated?.GetInvocationList(); + if (list != null) + { + return list.Length; + } + else + { + return 0; + } + } } } }