From 76a3f2d9e70a4a12a5e4450d4ddaeda480f56cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JasonXuDeveloper=20-=20=E5=82=91?= Date: Mon, 26 Jun 2023 20:32:11 +1000 Subject: [PATCH] fixed #485 --- .../Adapters/MonoBehaviourAdapter.cs | 7 ++++--- .../JEngine/Core/Manager/LifeCycleMgr.cs | 19 +++++++++++------- .../JEngine/Templates/MonoAdapter.txt | 7 ++++--- .../Main/Dll/Hidden~/HotUpdateScripts.dll | Bin 72704 -> 72704 bytes .../Main/Dll/Hidden~/HotUpdateScripts.pdb | Bin 26280 -> 26280 bytes .../Main/Dll/HotUpdateScripts.bytes | Bin 72720 -> 72720 bytes .../Main/Dll/HotUpdateScripts.pdb.bytes | Bin 26280 -> 26280 bytes 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/UnityProject/Assets/Dependencies/JEngine/Core/ILRuntimeHelper/Adapters/MonoBehaviourAdapter.cs b/UnityProject/Assets/Dependencies/JEngine/Core/ILRuntimeHelper/Adapters/MonoBehaviourAdapter.cs index 810e7ea6..d873edb5 100644 --- a/UnityProject/Assets/Dependencies/JEngine/Core/ILRuntimeHelper/Adapters/MonoBehaviourAdapter.cs +++ b/UnityProject/Assets/Dependencies/JEngine/Core/ILRuntimeHelper/Adapters/MonoBehaviourAdapter.cs @@ -142,10 +142,11 @@ public void Awake() //就mono订阅start和update事件 LifeCycleMgr.Instance.AddStartItem(instance, GetMethodInfo(type, "Start")); LifeCycleMgr.Instance.AddFixedUpdateItem(instance, GetMethodInfo(type, "FixedUpdate"), - gameObject); - LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject); + gameObject, ()=> enabled); + LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject, + () => enabled); LifeCycleMgr.Instance.AddLateUpdateItem(instance, GetMethodInfo(type, "LateUpdate"), - gameObject); + gameObject, () => enabled); isAwaking = false; awaked = true; diff --git a/UnityProject/Assets/Dependencies/JEngine/Core/Manager/LifeCycleMgr.cs b/UnityProject/Assets/Dependencies/JEngine/Core/Manager/LifeCycleMgr.cs index 5d8fb7e3..9ba46d3d 100644 --- a/UnityProject/Assets/Dependencies/JEngine/Core/Manager/LifeCycleMgr.cs +++ b/UnityProject/Assets/Dependencies/JEngine/Core/Manager/LifeCycleMgr.cs @@ -134,7 +134,7 @@ public static void Initialize() /// /// 最大数量 /// - private const int MaxSize = 10000; + private const int MaxSize = 30000; /// /// 锁 @@ -286,12 +286,13 @@ public void AddUpdateItem(object instance, MethodInfo method) /// /// /// - public void AddUpdateItem(T instance, MethodInfo method, GameObject parent) where T : class + /// + public void AddUpdateItem(T instance, MethodInfo method, GameObject parent, Func cond = null) where T : class { void* ptr = UnsafeUtility.PinGCObjectAndGetAddress(instance, out var address); _updateItems.Add(GetLifeCycleItem(in ptr, in address, () => method?.Invoke(instance, ConstMgr.NullObjects), - () => parent.activeInHierarchy)); + () => cond == null ? parent.activeInHierarchy : parent.activeInHierarchy && cond.Invoke())); } /// @@ -360,11 +361,13 @@ public void AddLateUpdateItem(object instance, MethodInfo method) /// /// /// - public void AddLateUpdateItem(T instance, MethodInfo method, GameObject parent) where T : class + /// + public void AddLateUpdateItem(T instance, MethodInfo method, GameObject parent, Func cond = null) where T : class { void* ptr = UnsafeUtility.PinGCObjectAndGetAddress(instance, out var address); _lateUpdateItems.Add(GetLifeCycleItem(in ptr, in address, - () => method?.Invoke(instance, ConstMgr.NullObjects), () => parent.activeInHierarchy)); + () => method?.Invoke(instance, ConstMgr.NullObjects), + () => cond == null ? parent.activeInHierarchy : parent.activeInHierarchy && cond.Invoke())); } /// @@ -404,11 +407,13 @@ public void AddFixedUpdateItem(object instance, MethodInfo method) /// /// /// - public void AddFixedUpdateItem(T instance, MethodInfo method, GameObject parent) where T : class + /// + public void AddFixedUpdateItem(T instance, MethodInfo method, GameObject parent, Func cond = null) where T : class { void* ptr = UnsafeUtility.PinGCObjectAndGetAddress(instance, out var address); _fixedUpdateItems.Add(GetLifeCycleItem(in ptr, in address, - () => method?.Invoke(instance, ConstMgr.NullObjects), () => parent.activeInHierarchy)); + () => method?.Invoke(instance, ConstMgr.NullObjects), + () => cond == null ? parent.activeInHierarchy : parent.activeInHierarchy && cond.Invoke())); } /// diff --git a/UnityProject/Assets/Dependencies/JEngine/Templates/MonoAdapter.txt b/UnityProject/Assets/Dependencies/JEngine/Templates/MonoAdapter.txt index c10e066e..325a218f 100644 --- a/UnityProject/Assets/Dependencies/JEngine/Templates/MonoAdapter.txt +++ b/UnityProject/Assets/Dependencies/JEngine/Templates/MonoAdapter.txt @@ -36,10 +36,11 @@ //就mono订阅start和update事件 LifeCycleMgr.Instance.AddStartItem(instance, GetMethodInfo(type, "Start")); LifeCycleMgr.Instance.AddFixedUpdateItem(instance, GetMethodInfo(type, "FixedUpdate"), - gameObject); - LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject); + gameObject, ()=> enabled); + LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject, + () => enabled); LifeCycleMgr.Instance.AddLateUpdateItem(instance, GetMethodInfo(type, "LateUpdate"), - gameObject); + gameObject, () => enabled); isAwaking = false; awaked = true; diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.dll b/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.dll index 64106d6816db76033bd66c0a9a6ef2787a7d210f..3cde53cf622d06ec9d4f3df0502c2bb513506dd8 100644 GIT binary patch delta 109 zcmZqJ!P2mUWkLt@i;S5YyHkG(SkJIjRC`hA-?>F*{>qyoF`Ir(kYthRpV2&hiZG*z zz$4jTE4KZscU=40_<-cW+}!OqgctGjIR^ delta 109 zcmZqJ!P2mUWkLt@^tUrMcBlRn5VMWGBC+6))9k4RE6Y9DS8Vz#!z9P2929ymOfoMRmG2gn`v!l7iIj( F1_0aUEA9XQ diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.pdb b/UnityProject/Assets/HotUpdateResources/Main/Dll/Hidden~/HotUpdateScripts.pdb index 6da5b8c82867adfda8819049b6b6f5350f4044b8..b76e7f9f1718e5d31c6a6b4dc38bb8d51f77835a 100644 GIT binary patch delta 63 zcmV-F0KosK%>k&*0g!wY;vM>^w*G%Xt?M(u8NqFB9FLfTv5;mh7&*@^(EvaL0JasA Vone#nM35&7Z@z^dld}#knmExu9B2Rl delta 63 zcmV-F0KosK%>k&*0g!wY5odBEB)RWEvo9u_gU1s*L=>8+v5;mh7~)+>zW_i309U+S V%gtn2Nrhp5R8>;-Z?g_Anm9z;8Uz3U diff --git a/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.bytes b/UnityProject/Assets/HotUpdateResources/Main/Dll/HotUpdateScripts.bytes index 2f7a32989e63a2427dbca3ffa51d8fb4f4f7ce02..cb5bfbd36442066642347d5bdfa576c0eb081167 100644 GIT binary patch delta 164 zcmV;V09*f%xCD^61dxCbn}(>n!sL|WV-a4mo4ckZv5;W-5P3`K`Clj`eX~l0b0jAA z#xNN5o6#)m`drSua delta 164 zcmV;V09*f%xCD^61dxCbi#f->x%L1twcd$lwdsxRv5;W-5Yg{*)s3B^Y^bPMhK6$D z_Okkr84y-&ZrmO;58mXNZ2-D9Zzq?a69FI~iHrbl1`W7O-obD#MsT*(%S@JpiYieq zGQpc2IoERJr{EI-0Wi#znYyZg#aM>hG5of_QyIk&*0g!wY;vM>^w*G%Xt?M(u8NqFB9FLfTv5;mh7&*@^(EvaL0JasA Vone#nM35&7Z@z^dld}#knmExu9B2Rl delta 63 zcmV-F0KosK%>k&*0g!wY5odBEB)RWEvo9u_gU1s*L=>8+v5;mh7~)+>zW_i309U+S V%gtn2Nrhp5R8>;-Z?g_Anm9z;8Uz3U