111
This commit is contained in:
@@ -22,52 +22,33 @@ namespace Tuan.GameFramework
|
||||
}
|
||||
public async UniTask Execute()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
CheckIsOffline();
|
||||
#endif
|
||||
if (!await operation.InitializePackage()) return;
|
||||
var version = await GetBestPackageVersion();
|
||||
#if UNITY_EDITOR
|
||||
if (!await operation.RequestPackageVersion()) return;
|
||||
version = operation.packageVersion;
|
||||
#endif
|
||||
if (!await operation.RequestPackageVersion())
|
||||
{
|
||||
operation.packageVersion = await operation.GetBuildinPackageVersion();
|
||||
}
|
||||
//获取版本失败
|
||||
if (version == null)
|
||||
if (operation.packageVersion == null)
|
||||
{
|
||||
MessageBox.Show()
|
||||
.SetTitle($"{operation.data.packageName}获取版本")
|
||||
.SetContent("获取版本失败")
|
||||
.AddButton("退出", (box) => { Application.Quit(); });
|
||||
.AddButton("退出", (box) =>
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
});
|
||||
return;
|
||||
}
|
||||
operation.packageVersion = version;
|
||||
if (!await operation.UpdatePackageManifest()) return;
|
||||
await HotDllLoader.Inst.LoadDll(YooAssets.GetPackage("Preload"), "GameScripts.Preload");
|
||||
await LoadAndShowPatchWindow();
|
||||
MainUICanvas.Inst.InitBg.SetActive(false);
|
||||
_ = UpdatePreloadPackage();
|
||||
}
|
||||
void CheckIsOffline()
|
||||
{
|
||||
if (string.IsNullOrEmpty(operation.GetCachedPackageVersion()))
|
||||
{
|
||||
operation.data.playMode = EPlayMode.OfflinePlayMode;
|
||||
}
|
||||
}
|
||||
async Task<string> GetBestPackageVersion()
|
||||
{
|
||||
string cachedVersion = operation.GetCachedPackageVersion();
|
||||
if (!string.IsNullOrEmpty(cachedVersion))
|
||||
{
|
||||
return cachedVersion;
|
||||
}
|
||||
string buildinVersion = await operation.GetBuildinPackageVersion();
|
||||
if (!string.IsNullOrEmpty(buildinVersion))
|
||||
{
|
||||
return buildinVersion;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private async UniTask LoadAndShowPatchWindow()
|
||||
{
|
||||
var assetHandle = operation.package.LoadAssetAsync<GameObject>("PatchWindow");
|
||||
@@ -82,9 +63,9 @@ namespace Tuan.GameFramework
|
||||
if (!await operation.UpdatePackageManifest(false)) return;
|
||||
if (operation.CreateDownloader())
|
||||
{
|
||||
if (!await operation.DownloadPackageFiles()) return;
|
||||
if (!await operation.DownloadPackageFiles(false)) return;
|
||||
}
|
||||
if (!await operation.ClearCacheBundle()) return;
|
||||
if (!await operation.ClearCacheBundle(false)) return;
|
||||
operation.SaveVersionToCache();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user