From 5734d4f9958c1b2010c0df0e8b4e770901fc64b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=8C=BA?= Date: Tue, 9 Jul 2024 16:11:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E7=83=AD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=A8=8B=E5=BA=8F=E9=9B=86=E7=9A=84=E5=B4=A9=E6=BA=83?= =?UTF-8?q?bug=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Main/Procedure/ProcedureLoadAssembly.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureLoadAssembly.cs b/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureLoadAssembly.cs index b8090917..34b90dfe 100644 --- a/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureLoadAssembly.cs +++ b/UnityProject/Assets/GameScripts/Main/Procedure/ProcedureLoadAssembly.cs @@ -9,6 +9,7 @@ using UnityEngine; using TEngine; using System.Reflection; using YooAsset; +using Cysharp.Threading.Tasks; namespace GameMain { @@ -38,6 +39,12 @@ namespace GameMain base.OnEnter(procedureOwner); Log.Debug("HyBridCLR ProcedureLoadAssembly OnEnter"); m_procedureOwner = procedureOwner; + + LoadAssembly().Forget(); + } + + private async UniTaskVoid LoadAssembly() + { m_LoadAssemblyComplete = false; m_HotfixAssemblys = new List(); @@ -55,7 +62,7 @@ namespace GameMain { m_LoadMetadataAssemblyComplete = true; } - + if (!SettingsUtils.HybridCLRCustomGlobalSettings.Enable || GameModule.Resource.PlayMode == EPlayMode.EditorSimulateMode) { m_MainLogicAssembly = GetMainLogicAssembly(); @@ -75,10 +82,11 @@ namespace GameMain SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath, $"{hotUpdateDllName}{SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetExtension}")); } - + Log.Debug($"LoadAsset: [ {assetLocation} ]"); m_LoadAssetCount++; - GameModule.Resource.LoadAsset(assetLocation,LoadAssetSuccess); + var result = await GameModule.Resource.LoadAssetAsync(assetLocation); + LoadAssetSuccess(result); } m_LoadAssemblyWait = true; @@ -94,7 +102,7 @@ namespace GameMain m_LoadAssemblyComplete = true; } } - + protected override void OnUpdate(IFsm procedureOwner, float elapseSeconds, float realElapseSeconds) { base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds); @@ -108,7 +116,7 @@ namespace GameMain } AllAssemblyLoadComplete(); } - + private void AllAssemblyLoadComplete() { ChangeState(m_procedureOwner); @@ -231,11 +239,11 @@ namespace GameMain SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath, $"{aotDllName}{SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetExtension}")); } - - + + Log.Debug($"LoadMetadataAsset: [ {assetLocation} ]"); m_LoadMetadataAssetCount++; - GameModule.Resource.LoadAsset(assetLocation,LoadMetadataAssetSuccess); + GameModule.Resource.LoadAsset(assetLocation, LoadMetadataAssetSuccess); } m_LoadMetadataAssemblyWait = true; } From 9afda7873517c2ebfd3dfea2f109ef7fd966f64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=8C=BA?= Date: Tue, 9 Jul 2024 17:23:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3GameApp=5FRegisterSystem?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=BC=8F=E5=86=99=E5=9F=BA=E7=B1=BB=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9C=9F=E6=9C=BA=E4=B8=8A=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E6=89=A7=E8=A1=8CGameApp.Instance.Active=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HotFix/GameLogic/GameApp_RegisterSystem.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs b/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs index 357f72a1..9c592297 100644 --- a/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs +++ b/UnityProject/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs @@ -3,10 +3,10 @@ using GameLogic; using TEngine; using UnityEngine; -public partial class GameApp +public partial class GameApp : Singleton { private List _listLogicMgr; - + public override void Active() { CodeTypes.Instance.Init(_hotfixAssembly.ToArray()); @@ -15,13 +15,13 @@ public partial class GameApp RegisterAllSystem(); InitSystemSetting(); } - + /// /// 设置一些通用的系统属性。 /// private void InitSystemSetting() { - + } /// @@ -32,7 +32,7 @@ public partial class GameApp //带生命周期的单例系统。 AddLogicSys(BehaviourSingleSystem.Instance); } - + /// /// 注册逻辑系统。 /// From e53ceb0095b70f1d607785fcbcd72f876b890d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=8C=BA?= Date: Tue, 9 Jul 2024 18:49:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8D=95=E4=BE=8B=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E9=94=80=E6=AF=81=E6=97=B6=E7=9A=84=E6=A3=80=E6=9F=A5=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=B1=E6=AD=A4=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=94=80=E6=AF=81=E5=8D=95=E4=BE=8B=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameScripts/HotFix/GameBase/SingletonBehaviour.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs b/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs index 91010dbc..16f3f067 100644 --- a/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs +++ b/UnityProject/Assets/GameScripts/HotFix/GameBase/SingletonBehaviour.cs @@ -36,7 +36,10 @@ namespace GameBase protected virtual void OnDestroy() { - Release(); + if (this == _instance) + { + Release(); + } } /// @@ -60,7 +63,7 @@ namespace GameBase if (_instance != null) { SingletonSystem.Release(_instance.gameObject); - _instance = null; + _instance = null; } } @@ -96,7 +99,7 @@ namespace GameBase } } - if(_instance == null) + if (_instance == null) { Log.Error($"Can't create SingletonBehaviour<{typeof(T)}>"); }