78 lines
2.9 KiB
C#
78 lines
2.9 KiB
C#
|
|
using Cysharp.Threading.Tasks;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using YooAsset;
|
|||
|
|
|
|||
|
|
public class MainOperation
|
|||
|
|
{
|
|||
|
|
PatchOperationData data;
|
|||
|
|
PatchOperation operation;
|
|||
|
|
public MainOperation(EPlayMode playMode)
|
|||
|
|
{
|
|||
|
|
data = new PatchOperationData();
|
|||
|
|
data.packageName = "Main";
|
|||
|
|
data.playMode = playMode;
|
|||
|
|
data.useBuildinFileSystem = false;
|
|||
|
|
data.downloadingMaxNum = 10;
|
|||
|
|
data.failedTryAgain = 3;
|
|||
|
|
|
|||
|
|
operation = new PatchOperation(data);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public async UniTask Execute()
|
|||
|
|
{
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
var PackageVersionOperation = await operation.RequestPackageVersion();
|
|||
|
|
if (PackageVersionOperation.Status != EOperationStatus.Succeed)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show()
|
|||
|
|
.SetTitle(operation.data.packageName)
|
|||
|
|
.SetContent($"{PackageVersionOperation.Error}")
|
|||
|
|
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
operation.packageVersion = PackageVersionOperation.PackageVersion;
|
|||
|
|
var PackageManifestOperation = await operation.UpdatePackageManifest();
|
|||
|
|
if (PackageManifestOperation.Status != EOperationStatus.Succeed)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show()
|
|||
|
|
.SetTitle(operation.data.packageName)
|
|||
|
|
.SetContent($"{PackageManifestOperation.Error}")
|
|||
|
|
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var DownloaderOperation = operation.CreateDownloader();
|
|||
|
|
if (DownloaderOperation.TotalDownloadCount == 0)
|
|||
|
|
{
|
|||
|
|
operation.SaveVersionToCache();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (!await operation.DownloadPackageFiles())
|
|||
|
|
{
|
|||
|
|
MessageBox.Show()
|
|||
|
|
.SetTitle(operation.data.packageName)
|
|||
|
|
.SetContent($"{DownloaderOperation.Error}")
|
|||
|
|
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var ClearCacheFilesOperation = await operation.ClearCacheBundle();
|
|||
|
|
if (ClearCacheFilesOperation.Status != EOperationStatus.Succeed)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show()
|
|||
|
|
.SetTitle(operation.data.packageName)
|
|||
|
|
.SetContent($"{ClearCacheFilesOperation.Error}")
|
|||
|
|
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
operation.SaveVersionToCache();
|
|||
|
|
}
|
|||
|
|
}
|