40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using System;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Utils.Editor
|
|
{
|
|
[CustomEditor(typeof(EventManager), true)]
|
|
public class EventManagerEditor : UnityEditor.Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
Event("EarlyUpdate", App.EarlyUpdateLength, App.EarlyUpdateDelegates);
|
|
EditorGUILayout.Space();
|
|
Event("Update", App.UpdateLength, App.UpdateDelegates);
|
|
EditorGUILayout.Space();
|
|
Event("LateUpdate", App.LateUpdateLength, App.LateUpdateDelegates);
|
|
EditorGUILayout.Space();
|
|
Event("LastUpdate", App.LastUpdateLength, App.LastUpdateDelegates);
|
|
}
|
|
|
|
private void Event(string title, int length, Delegate[] delegates)
|
|
{
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
|
|
GUILayout.Label(title, EditorStyles.boldLabel);
|
|
GUILayout.FlexibleSpace();
|
|
GUILayout.Label(length.ToString());
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
if (length == 0) return;
|
|
foreach (var d in delegates)
|
|
{
|
|
GUILayout.Label($"{d.Method.DeclaringType}.{d.Method.Name}", EditorStyles.miniLabel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |