Skip to content

Commit

Permalink
加载热更新程序集的崩溃bug修正
Browse files Browse the repository at this point in the history
  • Loading branch information
沈挺 committed Jul 9, 2024
1 parent dc7ab7f commit 5734d4f
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using TEngine;
using System.Reflection;
using YooAsset;
using Cysharp.Threading.Tasks;

namespace GameMain
{
Expand Down Expand Up @@ -38,6 +39,12 @@ protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
base.OnEnter(procedureOwner);
Log.Debug("HyBridCLR ProcedureLoadAssembly OnEnter");
m_procedureOwner = procedureOwner;

LoadAssembly().Forget();
}

private async UniTaskVoid LoadAssembly()
{
m_LoadAssemblyComplete = false;
m_HotfixAssemblys = new List<Assembly>();

Expand All @@ -55,7 +62,7 @@ protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
{
m_LoadMetadataAssemblyComplete = true;
}

if (!SettingsUtils.HybridCLRCustomGlobalSettings.Enable || GameModule.Resource.PlayMode == EPlayMode.EditorSimulateMode)
{
m_MainLogicAssembly = GetMainLogicAssembly();
Expand All @@ -75,10 +82,11 @@ protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath,
$"{hotUpdateDllName}{SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetExtension}"));
}

Log.Debug($"LoadAsset: [ {assetLocation} ]");
m_LoadAssetCount++;
GameModule.Resource.LoadAsset<TextAsset>(assetLocation,LoadAssetSuccess);
var result = await GameModule.Resource.LoadAssetAsync<TextAsset>(assetLocation);
LoadAssetSuccess(result);
}

m_LoadAssemblyWait = true;
Expand All @@ -94,7 +102,7 @@ protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
m_LoadAssemblyComplete = true;
}
}

protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
Expand All @@ -108,7 +116,7 @@ protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float e
}
AllAssemblyLoadComplete();
}

private void AllAssemblyLoadComplete()
{
ChangeState<ProcedureStartGame>(m_procedureOwner);
Expand Down Expand Up @@ -231,11 +239,11 @@ public void LoadMetadataForAOTAssembly()
SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath,
$"{aotDllName}{SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetExtension}"));
}


Log.Debug($"LoadMetadataAsset: [ {assetLocation} ]");
m_LoadMetadataAssetCount++;
GameModule.Resource.LoadAsset<TextAsset>(assetLocation,LoadMetadataAssetSuccess);
GameModule.Resource.LoadAsset<TextAsset>(assetLocation, LoadMetadataAssetSuccess);
}
m_LoadMetadataAssemblyWait = true;
}
Expand Down

0 comments on commit 5734d4f

Please sign in to comment.