This commit is contained in:
陈思海 2026-04-14 11:24:09 +08:00
parent 8cb9f1f6bc
commit 30da2271bd
8 changed files with 57 additions and 63 deletions

View File

@ -43,13 +43,14 @@ namespace Unity.Startup.Procedure
catch (Exception e) catch (Exception e)
{ {
Log.Exception(e); Log.Exception(e);
if (currentTryCount > MaxTryCount)
{
return;
}
await UniTask.Delay(3000); currentTryCount++;
GetAppVersionInfo();
if (currentTryCount <= MaxTryCount)
{
await UniTask.Delay(3000);
GetAppVersionInfo();
}
} }
} }
} }

View File

@ -7,6 +7,7 @@ namespace Unity.Startup.Procedure
internal sealed class ProcedureInitPackageState : ProcedureBase internal sealed class ProcedureInitPackageState : ProcedureBase
{ {
private int maxFailedCount = 0; private int maxFailedCount = 0;
private const int MAX_FAILED_TRYCOUNT = 3;
protected override void OnEnter() protected override void OnEnter()
{ {
@ -20,6 +21,7 @@ namespace Unity.Startup.Procedure
{ {
hostUrl = StartupSetting.CDNUrl; hostUrl = StartupSetting.CDNUrl;
} }
await GameApp.Resource.InitPackageAsync(string.Empty, hostUrl, hostUrl); await GameApp.Resource.InitPackageAsync(string.Empty, hostUrl, hostUrl);
await UniTask.DelayFrame(); await UniTask.DelayFrame();
UpdateStaticVersion().Forget(); UpdateStaticVersion().Forget();
@ -37,15 +39,21 @@ namespace Unity.Startup.Procedure
GameApp.Resource.PackageVersion = packageVersion; GameApp.Resource.PackageVersion = packageVersion;
Log.Info($"Updated package Version : {packageVersion}"); Log.Info($"Updated package Version : {packageVersion}");
maxFailedCount = 0;
UpdateManifest().Forget(); UpdateManifest().Forget();
} }
else else
{ {
maxFailedCount++;
//更新失败 //更新失败
Log.Error(buildInOperation.Error); Log.Error(buildInOperation.Error);
await UniTask.Delay(3000);
Log.Info("Retry Update Static Version"); if (maxFailedCount <= MAX_FAILED_TRYCOUNT)
UpdateStaticVersion().Forget(); {
await UniTask.Delay(3000);
UpdateStaticVersion().Forget();
Log.Info($"Retry Update Static Version...{maxFailedCount}");
}
} }
} }
@ -69,19 +77,19 @@ namespace Unity.Startup.Procedure
SwitchProcedure<ProcedurePatchDoneState>(); SwitchProcedure<ProcedurePatchDoneState>();
return; return;
} }
SwitchProcedure<ProcedureDownloadBundleState>(); SwitchProcedure<ProcedureDownloadBundleState>();
} }
else else
{ {
maxFailedCount++; maxFailedCount++;
Log.Error(buildInOperation.Error); Log.Error(buildInOperation.Error);
if (maxFailedCount >= 3) if (maxFailedCount <= MAX_FAILED_TRYCOUNT)
{ {
Log.Error(buildInOperation.Error); await UniTask.Delay(3000);
return; UpdateManifest().Forget();
Log.Info($"Retry Update Manifest Version...{maxFailedCount}");
} }
UpdateManifest().Forget();
} }
} }
} }

View File

@ -1,43 +1,27 @@
using System; #if ENABLE_HYBRIDCLR
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Reflection; using System.Reflection;
using AlicizaX; using AlicizaX;
using UnityEngine; using UnityEngine;
using YooAsset; using YooAsset;
#if ENABLE_HYBRIDCLR
using HybridCLR; using HybridCLR;
#endif
namespace Unity.Startup.Procedure namespace Unity.Startup.Procedure
{ {
public sealed class ProcedureLoadAssembly : ProcedureBase public sealed class ProcedureLoadAssembly : ProcedureBase
{ {
#if ENABLE_HYBRIDCLR
private int m_LoadAssetCount; private int m_LoadAssetCount;
private int m_LoadMetadataAssetCount; private int m_LoadMetadataAssetCount;
private int m_FailureAssetCount;
private int m_FailureMetadataAssetCount;
private bool m_LoadAssemblyComplete; private bool m_LoadAssemblyComplete;
private bool m_LoadMetadataAssemblyComplete; private bool m_LoadMetadataAssemblyComplete;
private bool m_LoadAssemblyWait; private bool m_LoadAssemblyWait;
#pragma warning disable CS0414
private bool m_LoadMetadataAssemblyWait; private bool m_LoadMetadataAssemblyWait;
#pragma warning restore CS0414
private Assembly m_MainLogicAssembly; private Assembly m_MainLogicAssembly;
private List<Assembly> m_HotfixAssemblys; private List<Assembly> m_HotfixAssemblys;
#endif
protected override void OnEnter() protected override void OnEnter()
{ {
#if !ENABLE_HYBRIDCLR
SwitchProcedure<ProcedureUpdateFinishState>();
return;
#endif
#if ENABLE_HYBRIDCLR
Log.Info(" ProcedureLoadAssembly OnEnter"); Log.Info(" ProcedureLoadAssembly OnEnter");
m_LoadAssemblyComplete = false; m_LoadAssemblyComplete = false;
m_HotfixAssemblys = new List<Assembly>(); m_HotfixAssemblys = new List<Assembly>();
@ -73,11 +57,8 @@ namespace Unity.Startup.Procedure
{ {
m_LoadAssemblyComplete = true; m_LoadAssemblyComplete = true;
} }
#endif
} }
#if ENABLE_HYBRIDCLR
protected override void OnUpdate() protected override void OnUpdate()
{ {
if (!m_LoadAssemblyComplete) if (!m_LoadAssemblyComplete)
@ -180,7 +161,6 @@ namespace Unity.Startup.Procedure
} }
catch (Exception e) catch (Exception e)
{ {
m_FailureAssetCount++;
Log.Error(e.Message); Log.Error(e.Message);
throw; throw;
} }
@ -246,7 +226,6 @@ namespace Unity.Startup.Procedure
} }
catch (Exception e) catch (Exception e)
{ {
m_FailureMetadataAssetCount++;
Log.Error(e.Message); Log.Error(e.Message);
throw; throw;
} }
@ -257,6 +236,7 @@ namespace Unity.Startup.Procedure
GameApp.Resource.UnloadAsset(textAsset); GameApp.Resource.UnloadAsset(textAsset);
} }
#endif
} }
} }
#endif

View File

@ -1,5 +1,4 @@
 using AlicizaX;
using AlicizaX;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using UnityEngine; using UnityEngine;
using YooAsset; using YooAsset;
@ -18,7 +17,12 @@ namespace Unity.Startup.Procedure
private void ClearCacheCompleted(AsyncOperationBase obj) private void ClearCacheCompleted(AsyncOperationBase obj)
{ {
Log.Info($"清理包裹缓存完成"); Log.Info($"清理包裹缓存完成");
#if ENABLE_HYBRIDCLR
SwitchProcedure<ProcedureLoadAssembly>(); SwitchProcedure<ProcedureLoadAssembly>();
#else
SwitchProcedure<ProcedureUpdateFinishState>();
#endif
} }
} }
} }

View File

@ -20,7 +20,9 @@ namespace Unity.Startup.Procedure
new ProcedureInitPackageState(), new ProcedureInitPackageState(),
new ProcedureDownloadBundleState(), new ProcedureDownloadBundleState(),
new ProcedurePatchDoneState(), new ProcedurePatchDoneState(),
#if ENABLE_HYBRIDCLR
new ProcedureLoadAssembly(), new ProcedureLoadAssembly(),
#endif
new ProcedureUpdateFinishState(), new ProcedureUpdateFinishState(),
}, },
typeof(ProcedureEntryState) typeof(ProcedureEntryState)

View File

@ -4,7 +4,6 @@
"references": [ "references": [
"UniTask.Runtime", "UniTask.Runtime",
"HybridCLR.Runtime", "HybridCLR.Runtime",
"AlicizaX.Entry.Runtime",
"YooAsset", "YooAsset",
"UniTask.YooAsset", "UniTask.YooAsset",
"HybridCLRGenerate", "HybridCLRGenerate",

@ -1 +1 @@
Subproject commit 43e6a6ba83ee3b108a51793a19529a61c36a908e Subproject commit ab0bc3bcf9902277859e8c9b18f07a7837bc37a5

View File

@ -174,7 +174,7 @@ MonoBehaviour:
m_MinSize: {x: 400, y: 100} m_MinSize: {x: 400, y: 100}
m_MaxSize: {x: 32384, y: 16192} m_MaxSize: {x: 32384, y: 16192}
vertical: 0 vertical: 0
controlID: 48 controlID: 159
draggingID: 0 draggingID: 0
--- !u!114 &8 --- !u!114 &8
MonoBehaviour: MonoBehaviour:
@ -221,12 +221,12 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 743 x: 743
y: 0 y: 0
width: 306 width: 172
height: 947 height: 947
m_MinSize: {x: 100, y: 100} m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 8096, y: 16192} m_MaxSize: {x: 8096, y: 16192}
vertical: 1 vertical: 1
controlID: 49 controlID: 70
draggingID: 0 draggingID: 0
--- !u!114 &10 --- !u!114 &10
MonoBehaviour: MonoBehaviour:
@ -245,7 +245,7 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 306 width: 172
height: 415 height: 415
m_MinSize: {x: 202, y: 221} m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4002, y: 4021}
@ -271,7 +271,7 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 415 y: 415
width: 306 width: 172
height: 532 height: 532
m_MinSize: {x: 102, y: 121} m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4002, y: 4021}
@ -295,9 +295,9 @@ MonoBehaviour:
m_Children: [] m_Children: []
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 1049 x: 915
y: 0 y: 0
width: 462 width: 596
height: 947 height: 947
m_MinSize: {x: 232, y: 271} m_MinSize: {x: 232, y: 271}
m_MaxSize: {x: 10002, y: 10021} m_MaxSize: {x: 10002, y: 10021}
@ -1163,9 +1163,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: -31257 x: 743
y: -31970 y: 73
width: 304 width: 170
height: 394 height: 394
m_SerializedDataModeController: m_SerializedDataModeController:
m_DataMode: 0 m_DataMode: 0
@ -1180,8 +1180,8 @@ MonoBehaviour:
m_SceneHierarchy: m_SceneHierarchy:
m_TreeViewState: m_TreeViewState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs: b0690000
m_LastClickedID: 0 m_LastClickedID: 27056
m_ExpandedIDs: 28fbffff m_ExpandedIDs: 28fbffff
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
@ -1228,7 +1228,7 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 743 x: 743
y: 488 y: 488
width: 304 width: 170
height: 511 height: 511
m_SerializedDataModeController: m_SerializedDataModeController:
m_DataMode: 0 m_DataMode: 0
@ -1260,9 +1260,9 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 1049 x: 915
y: 73 y: 73
width: 460 width: 594
height: 926 height: 926
m_SerializedDataModeController: m_SerializedDataModeController:
m_DataMode: 0 m_DataMode: 0
@ -1301,7 +1301,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: e48c0000 m_SelectedIDs: e48c0000
m_LastClickedID: 36068 m_LastClickedID: 36068
m_ExpandedIDs: 000000007e020000746a0000766a0000786a00007a6a00007c6a00007e6a0000806a0000826a0000846a0000866a0000886a00008a6a00008c6a00008e6a0000906a0000926a0000946a0000966a0000986a00009a6a00009c6a00009e6a0000a06a0000a26a0000a46a0000a66a0000a86a0000aa6a0000ac6a0000ae6a0000b06a0000b26a0000b46a0000b66a0000b86a0000ba6a0000bc6a0000be6a0000c06a0000c26a0000c46a0000c66a0000c86a0000ca6a0000cc6a0000ce6a0000d06a0000d26a0000d46a0000d66a0000d86a0000da6a0000dc6a0000de6a0000e06a0000e26a0000e46a0000e66a0000e86a0000ea6a0000ec6a0000ee6a0000f06a0000f26a0000f46a0000f66a0000f86a0000fa6a0000fc6a0000fe6a0000006b0000026b0000046b0000066b0000086b00000a6b00000c6b00000e6b0000106b0000126b0000146b0000166b0000186b00001a6b00001c6b00001e6b0000206b0000226b0000246b0000266b0000286b00002a6b00002c6b00002e6b0000306b0000326b0000346b0000366b0000386b00003a6b00003c6b00003e6b0000406b0000426b0000446b0000466b0000486b0000 m_ExpandedIDs: 000000007e020000886a00008a6a00008c6a00008e6a0000906a0000926a0000946a0000966a0000986a00009a6a00009c6a00009e6a0000a06a0000a26a0000a46a0000a66a0000a86a0000aa6a0000ac6a0000ae6a0000b06a0000b26a0000b46a0000b66a0000b86a0000ba6a0000bc6a0000be6a0000c06a0000c26a0000c46a0000c66a0000c86a0000ca6a0000cc6a0000ce6a0000d06a0000d26a0000d46a0000d66a0000d86a0000da6a0000dc6a0000de6a0000e06a0000e26a0000e46a0000e66a0000e86a0000ea6a0000ec6a0000ee6a0000f06a0000f26a0000f46a0000f66a0000f86a0000fa6a0000fc6a0000fe6a0000006b0000026b0000046b0000066b0000086b00000a6b00000c6b00000e6b0000106b0000126b0000146b0000166b0000186b00001a6b00001c6b00001e6b0000206b0000226b0000246b0000266b0000286b00002a6b00002c6b00002e6b0000306b0000326b0000346b0000366b0000386b00003a6b00003c6b00003e6b0000406b0000426b0000446b0000466b0000486b00004a6b00004c6b00004e6b0000506b0000526b0000546b0000566b0000586b00005a6b00005c6b0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -1329,21 +1329,21 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: ffffffff000000007e020000746a0000766a0000786a00007a6a00007c6a00007e6a0000806a0000826a0000846a0000866a0000886a00008a6a00008c6a00008e6a0000906a0000926a0000946a0000966a0000986a00009a6a00009c6a00009e6a0000a06a0000a26a0000a46a0000a66a0000a86a0000aa6a0000ac6a0000ae6a0000b06a0000b26a0000b46a0000b66a0000b86a0000ba6a0000bc6a0000be6a0000c06a0000c26a0000c46a0000c66a0000c86a0000ca6a0000cc6a0000ce6a0000d06a0000d26a0000d46a0000d66a0000d86a0000da6a0000dc6a0000de6a0000e06a0000e26a0000e46a0000e66a0000e86a0000ea6a0000ec6a0000ee6a0000f06a0000f26a0000f46a0000f66a0000f86a0000fa6a0000fc6a0000fe6a0000006b0000026b0000066b0000086b00000a6b00000c6b00000e6b0000106b0000126b0000146b0000166b0000186b00001a6b00001c6b00001e6b0000206b0000226b0000246b0000266b0000286b00002a6b00002c6b00002e6b0000306b0000326b0000346b0000366b0000386b00003a6b00003c6b00003e6b0000406b0000426b0000446b0000486b0000386d0000726f0000 m_ExpandedIDs: ffffffff000000007e020000886a00008a6a00008c6a00008e6a0000906a0000926a0000946a0000966a0000986a00009a6a00009c6a00009e6a0000a06a0000a26a0000a46a0000a66a0000a86a0000aa6a0000ac6a0000ae6a0000b06a0000b26a0000b46a0000b66a0000b86a0000ba6a0000bc6a0000be6a0000c06a0000c26a0000c46a0000c66a0000c86a0000ca6a0000cc6a0000ce6a0000d06a0000d26a0000d46a0000d66a0000d86a0000da6a0000dc6a0000de6a0000e06a0000e26a0000e46a0000e66a0000e86a0000ea6a0000ec6a0000ee6a0000f06a0000f26a0000f46a0000f66a0000f86a0000fa6a0000fc6a0000fe6a0000006b0000026b0000046b0000066b0000086b00000a6b00000c6b00000e6b0000106b0000126b0000146b0000166b0000186b00001a6b00001c6b00001e6b0000206b0000226b0000246b0000266b0000286b00002a6b00002c6b00002e6b0000306b0000326b0000346b0000366b0000386b00003a6b00003c6b00003e6b0000406b0000426b0000446b0000466b0000486b00004a6b00004c6b00004e6b0000506b0000526b0000546b0000566b0000586b00005a6b00005c6b0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: Btn@ETest m_Name:
m_OriginalName: Btn@ETest m_OriginalName:
m_EditFieldRect: m_EditFieldRect:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 0 width: 0
height: 0 height: 0
m_UserData: -2524 m_UserData: 0
m_IsWaitingForDelay: 0 m_IsWaitingForDelay: 0
m_IsRenaming: 0 m_IsRenaming: 0
m_OriginalEventType: 4 m_OriginalEventType: 11
m_IsRenamingFilename: 1 m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 12} m_ClientGUIView: {fileID: 12}
m_SearchString: m_SearchString: