From 5c6709513256fa81e44faada6ca3dbb5695ed3e1 Mon Sep 17 00:00:00 2001 From: Alexander Filippov Date: Mon, 29 Jan 2024 15:41:15 +0100 Subject: [PATCH] Added last update event. --- Runtime/EventManager.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Runtime/EventManager.cs b/Runtime/EventManager.cs index 0d7ba90..7eebbc0 100644 --- a/Runtime/EventManager.cs +++ b/Runtime/EventManager.cs @@ -5,17 +5,25 @@ namespace Utils public class EventManager : MonoBehaviour { public delegate void UpdateAction(); + public static event UpdateAction Updated; public delegate void FixedUpdateAction(); + public static event FixedUpdateAction FixedUpdated; public delegate void LateUpdateAction(); + public static event LateUpdateAction LateUpdated; - + public delegate void EarlyUpdateAction(); + public static event EarlyUpdateAction EarlyUpdated; + public delegate void LastUpdateAction(); + + public static event LastUpdateAction LastUpdated; + private void Update() { @@ -31,6 +39,7 @@ namespace Utils private void LateUpdate() { LateUpdated?.Invoke(); + LastUpdated?.Invoke(); } public static int UpdateLength @@ -59,7 +68,7 @@ namespace Utils return list?.Length ?? 0; } } - + public static int EarlyUpdateLength { get @@ -68,5 +77,14 @@ namespace Utils return list?.Length ?? 0; } } + + public static int LastUpdateLength + { + get + { + var list = LastUpdated?.GetInvocationList(); + return list?.Length ?? 0; + } + } } -} +} \ No newline at end of file