热更流程完成

This commit is contained in:
2025-11-03 17:46:28 +08:00
parent 75fb982872
commit db6f5d147e
43 changed files with 2596 additions and 326 deletions

View File

@@ -23,46 +23,27 @@ public class PreloadOperation
#if !UNITY_EDITOR
CheckIsOffline();
#endif
InitializationOperation initializationOperation = await operation.InitializePackage();
//<2F><>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7>
if (initializationOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{initializationOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
Debug.Log($"<22><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}");
if (!await operation.InitializePackage()) return;
var version = await GetBestPackageVersion();
#if UNITY_EDITOR
var PackageVersionOperation = await operation.RequestPackageVersion();
version = PackageVersionOperation.PackageVersion;
if (!await operation.RequestPackageVersion()) return;
version = operation.packageVersion;
#endif
//<EFBFBD><EFBFBD>ȡ<EFBFBD>汾ʧ<EFBFBD><EFBFBD>
//获取版本失败
if (version == null)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent("<EFBFBD><EFBFBD>ȡ<EFBFBD>汾ʧ<EFBFBD><EFBFBD>")
.AddButton("<EFBFBD>˳<EFBFBD>", (box) => { Application.Quit(); });
.SetTitle($"{operation.data.packageName}获取版本")
.SetContent("获取版本失败")
.AddButton("退出", (box) => { Application.Quit(); });
return;
}
operation.packageVersion = version;
Debug.Log($"<22><>ȡ<EFBFBD><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}<7D><>{version}");
UpdatePackageManifestOperation updatePackageManifest = await operation.UpdatePackageManifest();
//<2F><>ȡ<EFBFBD><C8A1>Դ<EFBFBD>嵥ʧ<E5B5A5><CAA7>
if (updatePackageManifest.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent(updatePackageManifest.Error)
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
if (!await operation.UpdatePackageManifest()) return;
await HotDllLoader.Inst.LoadDll(YooAssets.GetPackage("Preload"), "GameScripts.Preload");
await LoadAndShowPatchWindow();
GameManager.Inst.MainUICanvas.transform.Find("InitBg").gameObject.SetActive(false);
_ = UpdatePreloadPackage();
}
void CheckIsOffline()
{
@@ -91,41 +72,17 @@ public class PreloadOperation
await assetHandle.ToUniTask();
if (assetHandle.Status == EOperationStatus.Succeed)
GameObject.Instantiate(assetHandle.AssetObject, GameManager.Inst.MainUICanvas.transform);
Debug.Log("创建热更信息界面");
}
private async UniTask UpdatePreloadPackage()
{
var PackageVersionOperation = await operation.RequestPackageVersion();
if (PackageVersionOperation.Status != EOperationStatus.Succeed)
if (!await operation.RequestPackageVersion(false)) return;
if (!await operation.UpdatePackageManifest(false)) return;
if (operation.CreateDownloader())
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD><CCA8><EFBFBD>°汾ʧ<E6B1BE>ܣ<EFBFBD>{PackageVersionOperation.Error}");
return;
}
operation.packageVersion = PackageVersionOperation.PackageVersion;
var PackageManifestOperation = await operation.UpdatePackageManifest();
if (PackageManifestOperation.Status != EOperationStatus.Succeed)
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>嵥ʧ<E5B5A5>ܣ<EFBFBD>{PackageManifestOperation.Error}");
return;
}
var DownloaderOperation = operation.CreateDownloader();
if(DownloaderOperation.TotalDownloadCount == 0)
{
operation.SaveVersionToCache();
Debug.Log($"<22><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>{operation.data.packageName}<7D><><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><E6B1BE>{operation.packageVersion}");
return;
}
if (!await operation.DownloadPackageFiles())
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
return;
}
var ClearCacheFilesOperation = await operation.ClearCacheBundle();
if (ClearCacheFilesOperation.Status != EOperationStatus.Succeed)
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>δʹ<CEB4>û<EFBFBD><C3BB><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>{ClearCacheFilesOperation.Error}");
return;
if (!await operation.DownloadPackageFiles()) return;
}
if (!await operation.ClearCacheBundle()) return;
operation.SaveVersionToCache();
Debug.Log($"<22><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>{operation.data.packageName}<7D><><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><E6B1BE>{operation.packageVersion}");
}
}