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;