From 02e5d60ddc464934907f82a0849421986c94fb04 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Mon, 8 Aug 2022 17:24:03 +0800 Subject: [PATCH] Update MonoUtility.cs --- Assets/TEngine/Runtime/Core/MonoUtility.cs | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Assets/TEngine/Runtime/Core/MonoUtility.cs b/Assets/TEngine/Runtime/Core/MonoUtility.cs index 97939725..8b277918 100644 --- a/Assets/TEngine/Runtime/Core/MonoUtility.cs +++ b/Assets/TEngine/Runtime/Core/MonoUtility.cs @@ -87,7 +87,7 @@ namespace TEngine } #endregion - #region 注入UnityUpdate/FixedUpdate + #region 注入UnityUpdate/FixedUpdate/LateUpdate /// /// 为给外部提供的 添加帧更新事件 /// @@ -108,6 +108,16 @@ namespace TEngine _behaviour.AddFixedUpdateListener(fun); } + /// + /// 为给外部提供的 添加Late帧更新事件 + /// + /// + public static void AddLateUpdateListener(UnityAction fun) + { + _MakeEntity(); + _behaviour.AddLateUpdateListener(fun); + } + /// /// 移除帧更新事件 /// @@ -127,6 +137,16 @@ namespace TEngine _MakeEntity(); _behaviour.RemoveFixedUpdateListener(fun); } + + /// + /// 移除Late帧更新事件 + /// + /// + public static void RemoveLateUpdateListener(UnityAction fun) + { + _MakeEntity(); + _behaviour.RemoveLateUpdateListener(fun); + } #endregion private static void _MakeEntity() @@ -156,6 +176,7 @@ namespace TEngine { private event UnityAction updateEvent; private event UnityAction fixedUpdateEvent; + private event UnityAction lateUpdateEvent; void Update() { @@ -173,6 +194,24 @@ namespace TEngine } } + void LateUpdate() + { + if (lateUpdateEvent != null) + { + lateUpdateEvent(); + } + } + + public void AddLateUpdateListener(UnityAction fun) + { + lateUpdateEvent += fun; + } + + public void RemoveLateUpdateListener(UnityAction fun) + { + lateUpdateEvent -= fun; + } + public void AddFixedUpdateListener(UnityAction fun) { fixedUpdateEvent += fun;