Event Manager fixes

This commit is contained in:
Alexander Filippov 2021-08-16 16:05:42 +02:00
parent b0ba9167cf
commit 963d166bff
2 changed files with 43 additions and 10 deletions

View File

@ -8,13 +8,13 @@ namespace Utils
{ {
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
EventManager myTarget = (EventManager)target; EventManager eventManager = (EventManager)target;
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.Label("Update"); GUILayout.Label("Update");
if (Application.isPlaying) if (Application.isPlaying)
{ {
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(myTarget.UpdateLength().ToString()); GUILayout.Label(eventManager.UpdateLength.ToString());
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
@ -22,7 +22,7 @@ namespace Utils
if (Application.isPlaying) if (Application.isPlaying)
{ {
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(myTarget.FixedUpdateLength().ToString()); GUILayout.Label(eventManager.FixedUpdateLength.ToString());
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
@ -30,7 +30,7 @@ namespace Utils
if (Application.isPlaying) if (Application.isPlaying)
{ {
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(myTarget.LateUpdateLength().ToString()); GUILayout.Label(eventManager.LateUpdateLength.ToString());
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }

View File

@ -28,19 +28,52 @@ namespace Utils
OnLateUpdated?.Invoke(); 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;
}
}
} }
} }
} }