Show event manager methods. Remove fixed update.
This commit is contained in:
parent
5c67095132
commit
6b0bb3de6b
@ -1,4 +1,5 @@
|
|||||||
using UnityEditor;
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
@ -8,39 +9,32 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
var eventManager = (EventManager)target;
|
Event("EarlyUpdate", EventManager.EarlyUpdateLength, EventManager.EarlyUpdateDelegates);
|
||||||
GUILayout.BeginHorizontal();
|
EditorGUILayout.Space();
|
||||||
GUILayout.Label("Update");
|
Event("Update", EventManager.UpdateLength, EventManager.UpdateDelegates);
|
||||||
if (Application.isPlaying)
|
EditorGUILayout.Space();
|
||||||
|
Event("LateUpdate", EventManager.LateUpdateLength, EventManager.LateUpdateDelegates);
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
Event("LastUpdate", EventManager.LastUpdateLength, EventManager.LastUpdateDelegates);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Event(string title, int length, Delegate[] delegates)
|
||||||
{
|
{
|
||||||
GUILayout.FlexibleSpace();
|
|
||||||
GUILayout.Label(EventManager.UpdateLength.ToString());
|
|
||||||
}
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
GUILayout.Label("FixedUpdate");
|
|
||||||
if (Application.isPlaying)
|
|
||||||
{
|
{
|
||||||
GUILayout.FlexibleSpace();
|
|
||||||
GUILayout.Label(EventManager.FixedUpdateLength.ToString());
|
|
||||||
}
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
GUILayout.Label("LateUpdate");
|
|
||||||
if (Application.isPlaying)
|
GUILayout.Label(title, EditorStyles.boldLabel);
|
||||||
{
|
|
||||||
GUILayout.FlexibleSpace();
|
GUILayout.FlexibleSpace();
|
||||||
GUILayout.Label(EventManager.LateUpdateLength.ToString());
|
GUILayout.Label(length.ToString());
|
||||||
}
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
GUILayout.Label("EarlyUpdate");
|
if (length == 0) return;
|
||||||
if (Application.isPlaying)
|
foreach (var d in delegates)
|
||||||
{
|
{
|
||||||
GUILayout.FlexibleSpace();
|
GUILayout.Label($"{d.Method.DeclaringType}.{d.Method.Name}", EditorStyles.miniLabel);
|
||||||
GUILayout.Label(EventManager.EarlyUpdateLength.ToString());
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
@ -8,10 +9,6 @@ namespace Utils
|
|||||||
|
|
||||||
public static event UpdateAction Updated;
|
public static event UpdateAction Updated;
|
||||||
|
|
||||||
public delegate void FixedUpdateAction();
|
|
||||||
|
|
||||||
public static event FixedUpdateAction FixedUpdated;
|
|
||||||
|
|
||||||
public delegate void LateUpdateAction();
|
public delegate void LateUpdateAction();
|
||||||
|
|
||||||
public static event LateUpdateAction LateUpdated;
|
public static event LateUpdateAction LateUpdated;
|
||||||
@ -31,60 +28,26 @@ namespace Utils
|
|||||||
Updated?.Invoke();
|
Updated?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
|
||||||
{
|
|
||||||
FixedUpdated?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LateUpdate()
|
private void LateUpdate()
|
||||||
{
|
{
|
||||||
LateUpdated?.Invoke();
|
LateUpdated?.Invoke();
|
||||||
LastUpdated?.Invoke();
|
LastUpdated?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int UpdateLength
|
public static Delegate[] EarlyUpdateDelegates => EarlyUpdated?.GetInvocationList();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var list = Updated?.GetInvocationList();
|
|
||||||
return list?.Length ?? 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int FixedUpdateLength
|
public static int EarlyUpdateLength => EarlyUpdateDelegates?.Length ?? 0;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var list = FixedUpdated?.GetInvocationList();
|
|
||||||
return list?.Length ?? 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int LateUpdateLength
|
public static Delegate[] UpdateDelegates => Updated?.GetInvocationList();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var list = LateUpdated?.GetInvocationList();
|
|
||||||
return list?.Length ?? 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int EarlyUpdateLength
|
public static int UpdateLength => UpdateDelegates?.Length ?? 0;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var list = EarlyUpdated?.GetInvocationList();
|
|
||||||
return list?.Length ?? 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int LastUpdateLength
|
public static Delegate[] LateUpdateDelegates => LateUpdated?.GetInvocationList();
|
||||||
{
|
|
||||||
get
|
public static int LateUpdateLength => LateUpdateDelegates?.Length ?? 0;
|
||||||
{
|
|
||||||
var list = LastUpdated?.GetInvocationList();
|
public static Delegate[] LastUpdateDelegates => LastUpdated?.GetInvocationList();
|
||||||
return list?.Length ?? 0;
|
|
||||||
}
|
public static int LastUpdateLength => LastUpdateDelegates?.Length ?? 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ru.shazbot.utils",
|
"name": "ru.shazbot.utils",
|
||||||
"version": "5.2.0",
|
"version": "6.0.0",
|
||||||
"displayName": "Utils",
|
"displayName": "Utils",
|
||||||
"description": "Utility useful for almost any project.",
|
"description": "Utility useful for almost any project.",
|
||||||
"licensesUrl": "https://git.shazbot.ru/Utils.git/tree/LICENSE.md",
|
"licensesUrl": "https://git.shazbot.ru/Utils.git/tree/LICENSE.md",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user