update runtime code

pull/62/head
hevinci 2022-12-18 21:55:49 +08:00
parent 08ad68d4a2
commit 5c16171781
20 changed files with 782 additions and 819 deletions

View File

@ -663,28 +663,6 @@ namespace YooAsset
return _playModeServices.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout); return _playModeServices.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源定位列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
foreach (var location in locations)
{
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
}
return _playModeServices.CreatePatchDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件 /// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
/// </summary> /// </summary>

View File

@ -0,0 +1,69 @@

namespace YooAsset
{
/// <summary>
/// 内置补丁清单复制器
/// </summary>
internal class BuildinManifestCopyOperation : AsyncOperationBase
{
private enum ESteps
{
None,
CopyBuildinManifest,
CheckCopyBuildinManifest,
Done,
}
private readonly string _buildinPackageName;
private readonly string _buildinPackageVersion;
private UnityWebFileRequester _downloader;
private ESteps _steps = ESteps.None;
public BuildinManifestCopyOperation(string buildinPackageName, string buildinPackageVersion)
{
_buildinPackageName = buildinPackageName;
_buildinPackageVersion = buildinPackageVersion;
}
internal override void Start()
{
_steps = ESteps.CopyBuildinManifest;
}
internal override void Update()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CopyBuildinManifest)
{
string savePath = PersistentHelper.GetCacheManifestFilePath(_buildinPackageName);
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebFileRequester();
_downloader.SendRequest(url, savePath);
_steps = ESteps.CheckCopyBuildinManifest;
}
if (_steps == ESteps.CheckCopyBuildinManifest)
{
if (_downloader.IsDone() == false)
return;
if (_downloader.HasError())
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _downloader.GetError();
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
_downloader.Dispose();
}
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: c4b754a3b15abc44fa2727f57721e18b guid: 3a7685e67b0e948439ffba34513b78c0
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -0,0 +1,97 @@

namespace YooAsset
{
/// <summary>
/// 内置补丁清单加载器
/// </summary>
internal class BuildinManifestLoadOperation : AsyncOperationBase
{
private enum ESteps
{
None,
LoadBuildinManifest,
CheckLoadBuildinManifest,
CheckDeserializeManifest,
Done,
}
private readonly string _buildinPackageName;
private readonly string _buildinPackageVersion;
private UnityWebDataRequester _downloader;
private DeserializeManifestOperation _deserializer;
private ESteps _steps = ESteps.None;
/// <summary>
/// 加载结果
/// </summary>
public PatchManifest Manifest { private set; get; }
public BuildinManifestLoadOperation(string buildinPackageName, string buildinPackageVersion)
{
_buildinPackageName = buildinPackageName;
_buildinPackageVersion = buildinPackageVersion;
}
internal override void Start()
{
_steps = ESteps.LoadBuildinManifest;
}
internal override void Update()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadBuildinManifest)
{
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebDataRequester();
_downloader.SendRequest(url);
_steps = ESteps.CheckLoadBuildinManifest;
}
if (_steps == ESteps.CheckLoadBuildinManifest)
{
if (_downloader.IsDone() == false)
return;
if (_downloader.HasError())
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _downloader.GetError();
}
else
{
byte[] bytesData = _downloader.GetData();
_deserializer = new DeserializeManifestOperation(bytesData);
OperationSystem.StartOperation(_deserializer);
_steps = ESteps.CheckDeserializeManifest;
}
_downloader.Dispose();
}
if (_steps == ESteps.CheckDeserializeManifest)
{
Progress = _deserializer.Progress;
if (_deserializer.IsDone == false)
return;
if (_deserializer.Status == EOperationStatus.Succeed)
{
Manifest = _deserializer.Manifest;
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _deserializer.Error;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f3a2fe7d8d4747d43b3ac48097341e36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,81 @@

namespace YooAsset
{
/// <summary>
/// 内置补丁清单版本查询器
/// </summary>
internal class BuildinPackageVersionQueryOperation : AsyncOperationBase
{
private enum ESteps
{
None,
LoadPackageVersion,
CheckLoadPackageVersion,
Done,
}
private readonly string _packageName;
private UnityWebDataRequester _downloader;
private ESteps _steps = ESteps.None;
/// <summary>
/// 内置包裹版本
/// </summary>
public string Version { private set; get; }
public BuildinPackageVersionQueryOperation(string packageName)
{
_packageName = packageName;
}
internal override void Start()
{
_steps = ESteps.LoadPackageVersion;
}
internal override void Update()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadPackageVersion)
{
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebDataRequester();
_downloader.SendRequest(url);
_steps = ESteps.CheckLoadPackageVersion;
}
if (_steps == ESteps.CheckLoadPackageVersion)
{
if (_downloader.IsDone() == false)
return;
if (_downloader.HasError())
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _downloader.GetError();
}
else
{
Version = _downloader.GetText();
if (string.IsNullOrEmpty(Version))
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Buildin package version file content is empty !";
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
_downloader.Dispose();
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bdc251ea99d82e54199dfba540f2814d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,88 @@
using System.IO;
namespace YooAsset
{
/// <summary>
/// 沙盒补丁清单加载器
/// </summary>
internal class CacheManifestLoadOperation : AsyncOperationBase
{
private enum ESteps
{
None,
LoadCacheManifestFile,
CheckDeserializeManifest,
Done,
}
private readonly string _packageName;
private DeserializeManifestOperation _deserializer;
private ESteps _steps = ESteps.None;
private string _manifestFilePath;
/// <summary>
/// 加载结果
/// </summary>
public PatchManifest Manifest { private set; get; }
public CacheManifestLoadOperation(string packageName)
{
_packageName = packageName;
}
internal override void Start()
{
_steps = ESteps.LoadCacheManifestFile;
}
internal override void Update()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadCacheManifestFile)
{
_manifestFilePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
if (File.Exists(_manifestFilePath) == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Manifest file not found : {_manifestFilePath}";
return;
}
byte[] bytesData = File.ReadAllBytes(_manifestFilePath);
_deserializer = new DeserializeManifestOperation(bytesData);
OperationSystem.StartOperation(_deserializer);
_steps = ESteps.CheckDeserializeManifest;
}
if (_steps == ESteps.CheckDeserializeManifest)
{
Progress = _deserializer.Progress;
if (_deserializer.IsDone == false)
return;
if (_deserializer.Status == EOperationStatus.Succeed)
{
Manifest = _deserializer.Manifest;
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _deserializer.Error;
// 注意:如果加载沙盒内的清单报错,为了避免流程被卡住,我们主动把损坏的文件删除。
if (File.Exists(_manifestFilePath))
{
YooLogger.Warning($"Failed to load cache manifest file : {Error}");
YooLogger.Warning($"Invalid cache manifest file have been removed : {_manifestFilePath}");
File.Delete(_manifestFilePath);
}
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5067db2d5b2aa1240aef2f9a952a2e0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -153,6 +153,7 @@ namespace YooAsset
} }
catch(System.Exception e) catch(System.Exception e)
{ {
Manifest = null;
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = e.Message; Error = e.Message;

View File

@ -1,219 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
/*
namespace YooAsset
{
public abstract class DownloadPackageOperation : AsyncOperationBase
{
/// <summary>
/// 创建包裹下载器
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间(单位:秒)</param>
public abstract PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout);
}
/// <summary>
/// 编辑器下模拟运行的更新资源包裹操作
/// </summary>
internal sealed class EditorPlayModeDownloadPackageOperation : DownloadPackageOperation
{
internal override void Start()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
{
}
/// <summary>
/// 创建包裹下载器
/// </summary>
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
}
/// <summary>
/// 离线模式的更新资源包裹操作
/// </summary>
internal sealed class OfflinePlayModeDownloadPackageOperation : DownloadPackageOperation
{
internal override void Start()
{
Status = EOperationStatus.Succeed;
}
internal override void Update()
{
}
/// <summary>
/// 创建包裹下载器
/// </summary>
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
}
/// <summary>
/// 联机模式的更新资源包裹操作
/// </summary>
internal sealed class HostPlayModeDownloadPackageOperation : DownloadPackageOperation
{
private enum ESteps
{
None,
LoadWebManifest,
CheckLoadWebManifest,
CheckDeserializeManifest,
Done,
}
private static int RequestCount = 0;
private readonly HostPlayModeImpl _impl;
private readonly string _packageName;
private readonly string _packageVersion;
private readonly int _timeout;
private ESteps _steps = ESteps.None;
private UnityWebDataRequester _downloader;
private DeserializeManifestOperation _deserializer;
private PatchManifest _remotePatchManifest;
internal HostPlayModeDownloadPackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
{
_impl = impl;
_packageName = packageName;
_packageVersion = packageVersion;
_timeout = timeout;
}
internal override void Start()
{
RequestCount++;
_steps = ESteps.LoadWebManifest;
}
internal override void Update()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadWebManifest)
{
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_packageName, _packageVersion);
string webURL = GetPatchManifestRequestURL(fileName);
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
_downloader = new UnityWebDataRequester();
_downloader.SendRequest(webURL, _timeout);
_steps = ESteps.CheckLoadWebManifest;
}
if (_steps == ESteps.CheckLoadWebManifest)
{
Progress = _downloader.Progress();
if (_downloader.IsDone() == false)
return;
// Check error
if (_downloader.HasError())
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _downloader.GetError();
}
else
{
// 解析补丁清单
byte[] bytesData = _downloader.GetData();
_deserializer = new DeserializeManifestOperation(bytesData);
OperationSystem.StartOperation(_deserializer);
_steps = ESteps.CheckDeserializeManifest;
}
_downloader.Dispose();
}
if (_steps == ESteps.CheckDeserializeManifest)
{
Progress = _deserializer.Progress;
if (_deserializer.IsDone)
{
if (_deserializer.Status == EOperationStatus.Succeed)
{
_remotePatchManifest = _deserializer.Manifest;
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _deserializer.Error;
}
}
}
}
/// <summary>
/// 创建包裹下载器
/// </summary>
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
if (Status == EOperationStatus.Succeed)
{
YooLogger.Log($"Create package downloader : {_remotePatchManifest.PackageName} {_remotePatchManifest.PackageVersion}");
List<BundleInfo> downloadList = GetDownloadList();
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
else
{
YooLogger.Error($"{nameof(DownloadPackageOperation)} status is failed !");
var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
}
/// <summary>
/// 获取补丁清单请求地址
/// </summary>
private string GetPatchManifestRequestURL(string fileName)
{
// 轮流返回请求地址
if (RequestCount % 2 == 0)
return _impl.GetPatchDownloadFallbackURL(fileName);
else
return _impl.GetPatchDownloadMainURL(fileName);
}
/// <summary>
/// 获取下载列表
/// </summary>
private List<BundleInfo> GetDownloadList()
{
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in _remotePatchManifest.BundleList)
{
// 忽略缓存文件
if (CacheSystem.IsCached(patchBundle))
continue;
// 忽略APP资源
if (_impl.IsBuildinPatchBundle(patchBundle))
continue;
downloadList.Add(patchBundle);
}
return _impl.ConvertToDownloadList(downloadList);
}
}
}
*/

View File

@ -183,9 +183,9 @@ namespace YooAsset
{ {
var failedDownloader = _failedList[0]; var failedDownloader = _failedList[0];
string fileName = failedDownloader.GetBundleInfo().Bundle.BundleName; string fileName = failedDownloader.GetBundleInfo().Bundle.BundleName;
Error = $"Failed to download file : {fileName}";
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Failed to download file : {fileName}";
OnDownloadErrorCallback?.Invoke(fileName, failedDownloader.GetLastError()); OnDownloadErrorCallback?.Invoke(fileName, failedDownloader.GetLastError());
OnDownloadOverCallback?.Invoke(false); OnDownloadOverCallback?.Invoke(false);
} }
@ -241,19 +241,22 @@ namespace YooAsset
} }
} }
public sealed class PackageDownloaderOperation : DownloaderOperation
{
internal PackageDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{
}
}
public sealed class PatchDownloaderOperation : DownloaderOperation public sealed class PatchDownloaderOperation : DownloaderOperation
{ {
internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{ {
} }
/// <summary>
/// 创建空的下载器
/// </summary>
internal static PatchDownloaderOperation CreateEmptyDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
} }
public sealed class PatchUnpackerOperation : DownloaderOperation public sealed class PatchUnpackerOperation : DownloaderOperation
{ {
@ -261,5 +264,15 @@ namespace YooAsset
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{ {
} }
/// <summary>
/// 创建空的解压器
/// </summary>
internal static PatchUnpackerOperation CreateEmptyUnpacker(int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
return operation;
}
} }
} }

View File

@ -64,13 +64,13 @@ namespace YooAsset
if (_steps == ESteps.CheckDeserializeManifest) if (_steps == ESteps.CheckDeserializeManifest)
{ {
if (_deserializer.IsDone) if (_deserializer.IsDone == false)
{ return;
if (_deserializer.Status == EOperationStatus.Succeed) if (_deserializer.Status == EOperationStatus.Succeed)
{ {
var manifest = _deserializer.Manifest; InitializedPackageVersion = _deserializer.Manifest.PackageVersion;
InitializedPackageVersion = manifest.PackageVersion; _impl.ActivePatchManifest = _deserializer.Manifest;
_impl.ActivePatchManifest = manifest;
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
} }
@ -83,7 +83,6 @@ namespace YooAsset
} }
} }
} }
}
/// <summary> /// <summary>
/// 离线运行模式的初始化操作 /// 离线运行模式的初始化操作
@ -102,8 +101,8 @@ namespace YooAsset
private readonly OfflinePlayModeImpl _impl; private readonly OfflinePlayModeImpl _impl;
private readonly string _packageName; private readonly string _packageName;
private readonly BuildinPackageVersionQuerier _buildinPackageVersionQuerier; private BuildinPackageVersionQueryOperation _buildinPackageVersionQuery;
private BuildinManifestLoader _buildinManifestLoader; private BuildinManifestLoadOperation _buildinManifestLoad;
private CacheFilesVerifyOperation _verifyOperation; private CacheFilesVerifyOperation _verifyOperation;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private float _verifyTime; private float _verifyTime;
@ -112,7 +111,7 @@ namespace YooAsset
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_buildinPackageVersionQuerier = new BuildinPackageVersionQuerier(packageName);
} }
internal override void Start() internal override void Start()
{ {
@ -125,43 +124,50 @@ namespace YooAsset
if (_steps == ESteps.QueryBuildinPackageVersion) if (_steps == ESteps.QueryBuildinPackageVersion)
{ {
_buildinPackageVersionQuerier.Update(); if (_buildinPackageVersionQuery == null)
if (_buildinPackageVersionQuerier.IsDone == false) {
_buildinPackageVersionQuery = new BuildinPackageVersionQueryOperation(_packageName);
OperationSystem.StartOperation(_buildinPackageVersionQuery);
}
if (_buildinPackageVersionQuery.IsDone == false)
return; return;
string error = _buildinPackageVersionQuerier.Error; if (_buildinPackageVersionQuery.Status == EOperationStatus.Succeed)
if (string.IsNullOrEmpty(error) == false)
{ {
_steps = ESteps.Done; _steps = ESteps.LoadBuildinManifest;
Status = EOperationStatus.Failed;
Error = error;
} }
else else
{ {
_buildinManifestLoader = new BuildinManifestLoader(_packageName, _buildinPackageVersionQuerier.Version); _steps = ESteps.Done;
_steps = ESteps.LoadBuildinManifest; Status = EOperationStatus.Failed;
Error = _buildinPackageVersionQuery.Error;
} }
} }
if (_steps == ESteps.LoadBuildinManifest) if (_steps == ESteps.LoadBuildinManifest)
{ {
_buildinManifestLoader.Update(); if (_buildinManifestLoad == null)
Progress = _buildinManifestLoader.Progress; {
if (_buildinManifestLoader.IsDone == false) _buildinManifestLoad = new BuildinManifestLoadOperation(_packageName, _buildinPackageVersionQuery.Version);
OperationSystem.StartOperation(_buildinManifestLoad);
}
Progress = _buildinManifestLoad.Progress;
if (_buildinManifestLoad.IsDone == false)
return; return;
var manifest = _buildinManifestLoader.Manifest; if (_buildinManifestLoad.Status == EOperationStatus.Succeed)
if (manifest == null)
{ {
_steps = ESteps.Done; InitializedPackageVersion = _buildinManifestLoad.Manifest.PackageVersion;
Status = EOperationStatus.Failed; _impl.ActivePatchManifest = _buildinManifestLoad.Manifest;
Error = _buildinManifestLoader.Error; _steps = ESteps.StartVerifyOperation;
} }
else else
{ {
InitializedPackageVersion = manifest.PackageVersion; _steps = ESteps.Done;
_impl.ActivePatchManifest = manifest; Status = EOperationStatus.Failed;
_steps = ESteps.StartVerifyOperation; Error = _buildinManifestLoad.Error;
} }
} }
@ -213,10 +219,10 @@ namespace YooAsset
private readonly HostPlayModeImpl _impl; private readonly HostPlayModeImpl _impl;
private readonly string _packageName; private readonly string _packageName;
private readonly BuildinPackageVersionQuerier _buildinPackageVersionQuerier; private BuildinPackageVersionQueryOperation _buildinPackageVersionQuery;
private BuildinManifestCopyer _buildinManifestCopyer; private BuildinManifestCopyOperation _buildinManifestCopy;
private BuildinManifestLoader _buildinManifestLoader; private BuildinManifestLoadOperation _buildinManifestLoad;
private CacheManifestLoader _cacheManifestLoader; private CacheManifestLoadOperation _cacheManifestLoad;
private CacheFilesVerifyOperation _verifyOperation; private CacheFilesVerifyOperation _verifyOperation;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private float _verifyTime; private float _verifyTime;
@ -225,7 +231,6 @@ namespace YooAsset
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_buildinPackageVersionQuerier = new BuildinPackageVersionQuerier(packageName);
} }
internal override void Start() internal override void Start()
{ {
@ -253,17 +258,19 @@ namespace YooAsset
if (_steps == ESteps.TryLoadCacheManifest) if (_steps == ESteps.TryLoadCacheManifest)
{ {
if (_cacheManifestLoader == null) if (_cacheManifestLoad == null)
_cacheManifestLoader = new CacheManifestLoader(_packageName); {
_cacheManifestLoad = new CacheManifestLoadOperation(_packageName);
OperationSystem.StartOperation(_cacheManifestLoad);
}
_cacheManifestLoader.Update(); if (_cacheManifestLoad.IsDone == false)
if (_cacheManifestLoader.IsDone) return;
if (_cacheManifestLoad.Status == EOperationStatus.Succeed)
{ {
var manifest = _cacheManifestLoader.Manifest; InitializedPackageVersion = _cacheManifestLoad.Manifest.PackageVersion;
if (manifest != null) _impl.ActivePatchManifest = _cacheManifestLoad.Manifest;
{
InitializedPackageVersion = manifest.PackageVersion;
_impl.ActivePatchManifest = manifest;
_steps = ESteps.StartVerifyOperation; _steps = ESteps.StartVerifyOperation;
} }
else else
@ -271,69 +278,79 @@ namespace YooAsset
_steps = ESteps.QueryBuildinPackageVersion; _steps = ESteps.QueryBuildinPackageVersion;
} }
} }
}
if (_steps == ESteps.QueryBuildinPackageVersion) if (_steps == ESteps.QueryBuildinPackageVersion)
{ {
_buildinPackageVersionQuerier.Update(); if (_buildinPackageVersionQuery == null)
if (_buildinPackageVersionQuerier.IsDone == false) {
_buildinPackageVersionQuery = new BuildinPackageVersionQueryOperation(_packageName);
OperationSystem.StartOperation(_buildinPackageVersionQuery);
}
if (_buildinPackageVersionQuery.IsDone == false)
return; return;
// 注意为了兼容MOD模式初始化动态新增的包裹的时候如果内置清单不存在也不需要报错 // 注意为了兼容MOD模式初始化动态新增的包裹的时候如果内置清单不存在也不需要报错
string error = _buildinPackageVersionQuerier.Error; if (_buildinPackageVersionQuery.Status == EOperationStatus.Succeed)
if (string.IsNullOrEmpty(error) == false)
{ {
_steps = ESteps.Done; _steps = ESteps.CopyBuildinManifest;
Status = EOperationStatus.Succeed;
YooLogger.Log($"Failed to load buildin package version file : {error}");
} }
else else
{ {
_buildinManifestCopyer = new BuildinManifestCopyer(_packageName, _buildinPackageVersionQuerier.Version); _steps = ESteps.Done;
_buildinManifestLoader = new BuildinManifestLoader(_packageName, _buildinPackageVersionQuerier.Version); Status = EOperationStatus.Succeed;
_steps = ESteps.CopyBuildinManifest; string error = _buildinPackageVersionQuery.Error;
YooLogger.Log($"Failed to load buildin package version file : {error}");
} }
} }
if (_steps == ESteps.CopyBuildinManifest) if (_steps == ESteps.CopyBuildinManifest)
{ {
_buildinManifestCopyer.Update(); if (_buildinManifestCopy == null)
Progress = _buildinManifestCopyer.Progress; {
if (_buildinManifestCopyer.IsDone == false) _buildinManifestCopy = new BuildinManifestCopyOperation(_packageName, _buildinPackageVersionQuery.Version);
OperationSystem.StartOperation(_buildinManifestCopy);
}
Progress = _buildinManifestCopy.Progress;
if (_buildinManifestCopy.IsDone == false)
return; return;
string error = _buildinManifestCopyer.Error; if (_buildinManifestCopy.Status == EOperationStatus.Succeed)
if (string.IsNullOrEmpty(error) == false)
{ {
_steps = ESteps.Done; _steps = ESteps.LoadBuildinManifest;
Status = EOperationStatus.Failed;
Error = error;
} }
else else
{ {
_steps = ESteps.LoadBuildinManifest; _steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _buildinManifestCopy.Error;
} }
} }
if (_steps == ESteps.LoadBuildinManifest) if (_steps == ESteps.LoadBuildinManifest)
{ {
_buildinManifestLoader.Update(); if (_buildinManifestLoad == null)
Progress = _buildinManifestLoader.Progress; {
if (_buildinManifestLoader.IsDone == false) _buildinManifestLoad = new BuildinManifestLoadOperation(_packageName, _buildinPackageVersionQuery.Version);
OperationSystem.StartOperation(_buildinManifestLoad);
}
Progress = _buildinManifestLoad.Progress;
if (_buildinManifestLoad.IsDone == false)
return; return;
var manifest = _buildinManifestLoader.Manifest; if (_buildinManifestLoad.Status == EOperationStatus.Succeed)
if (manifest == null)
{ {
_steps = ESteps.Done; InitializedPackageVersion = _buildinManifestLoad.Manifest.PackageVersion;
Status = EOperationStatus.Failed; _impl.ActivePatchManifest = _buildinManifestLoad.Manifest;
Error = _buildinManifestLoader.Error; _steps = ESteps.StartVerifyOperation;
} }
else else
{ {
InitializedPackageVersion = manifest.PackageVersion; _steps = ESteps.Done;
_impl.ActivePatchManifest = manifest; Status = EOperationStatus.Failed;
_steps = ESteps.StartVerifyOperation; Error = _buildinManifestLoad.Error;
} }
} }
@ -415,383 +432,4 @@ namespace YooAsset
YooLogger.Log($"Save application foot print : {_footPrint}"); YooLogger.Log($"Save application foot print : {_footPrint}");
} }
} }
/// <summary>
/// 内置补丁清单版本查询器
/// </summary>
internal class BuildinPackageVersionQuerier
{
private enum ESteps
{
LoadStaticVersion,
CheckStaticVersion,
Done,
}
private readonly string _buildinPackageName;
private ESteps _steps = ESteps.LoadStaticVersion;
private UnityWebDataRequester _downloader;
/// <summary>
/// 内置包裹版本
/// </summary>
public string Version { private set; get; }
/// <summary>
/// 错误日志
/// </summary>
public string Error { private set; get; }
/// <summary>
/// 是否已经完成
/// </summary>
public bool IsDone
{
get
{
return _steps == ESteps.Done;
}
}
public BuildinPackageVersionQuerier(string buildinPackageName)
{
_buildinPackageName = buildinPackageName;
}
/// <summary>
/// 更新流程
/// </summary>
public void Update()
{
if (IsDone)
return;
if (_steps == ESteps.LoadStaticVersion)
{
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_buildinPackageName);
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebDataRequester();
_downloader.SendRequest(url);
_steps = ESteps.CheckStaticVersion;
}
if (_steps == ESteps.CheckStaticVersion)
{
if (_downloader.IsDone() == false)
return;
if (_downloader.HasError())
{
Error = _downloader.GetError();
}
else
{
Version = _downloader.GetText();
if (string.IsNullOrEmpty(Version))
Error = $"Buildin package version file content is empty !";
}
_steps = ESteps.Done;
_downloader.Dispose();
}
}
}
/// <summary>
/// 内置补丁清单加载器
/// </summary>
internal class BuildinManifestLoader
{
private enum ESteps
{
LoadBuildinManifest,
CheckLoadBuildinManifest,
CheckDeserializeManifest,
Done,
}
private readonly string _buildinPackageName;
private readonly string _buildinPackageVersion;
private ESteps _steps = ESteps.LoadBuildinManifest;
private UnityWebDataRequester _downloader;
private DeserializeManifestOperation _deserializer;
/// <summary>
/// 加载结果
/// </summary>
public PatchManifest Manifest { private set; get; }
/// <summary>
/// 加载进度
/// </summary>
public float Progress { private set; get; }
/// <summary>
/// 错误日志
/// </summary>
public string Error { private set; get; }
/// <summary>
/// 是否已经完成
/// </summary>
public bool IsDone
{
get
{
return _steps == ESteps.Done;
}
}
public BuildinManifestLoader(string buildinPackageName, string buildinPackageVersion)
{
_buildinPackageName = buildinPackageName;
_buildinPackageVersion = buildinPackageVersion;
}
/// <summary>
/// 更新流程
/// </summary>
public void Update()
{
if (IsDone)
return;
if (_steps == ESteps.LoadBuildinManifest)
{
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebDataRequester();
_downloader.SendRequest(url);
_steps = ESteps.CheckLoadBuildinManifest;
}
if (_steps == ESteps.CheckLoadBuildinManifest)
{
if (_downloader.IsDone() == false)
return;
if (_downloader.HasError())
{
Error = _downloader.GetError();
_steps = ESteps.Done;
}
else
{
// 解析APP里的补丁清单
byte[] bytesData = _downloader.GetData();
_deserializer = new DeserializeManifestOperation(bytesData);
OperationSystem.StartOperation(_deserializer);
_steps = ESteps.CheckDeserializeManifest;
}
_downloader.Dispose();
}
if (_steps == ESteps.CheckDeserializeManifest)
{
Progress = _deserializer.Progress;
if (_deserializer.IsDone)
{
if (_deserializer.Status == EOperationStatus.Succeed)
{
Manifest = _deserializer.Manifest;
}
else
{
Error = _deserializer.Error;
}
_steps = ESteps.Done;
}
}
}
}
/// <summary>
/// 内置补丁清单复制器
/// </summary>
internal class BuildinManifestCopyer
{
private enum ESteps
{
CopyBuildinManifest,
CheckCopyBuildinManifest,
Done,
}
private readonly string _buildinPackageName;
private readonly string _buildinPackageVersion;
private ESteps _steps = ESteps.CopyBuildinManifest;
private UnityWebFileRequester _downloader;
/// <summary>
/// 错误日志
/// </summary>
public string Error { private set; get; }
/// <summary>
/// 是否已经完成
/// </summary>
public bool IsDone
{
get
{
return _steps == ESteps.Done;
}
}
/// <summary>
/// 加载进度
/// </summary>
public float Progress
{
get
{
if (_downloader == null)
return 0;
return _downloader.Progress();
}
}
public BuildinManifestCopyer(string buildinPackageName, string buildinPackageVersion)
{
_buildinPackageName = buildinPackageName;
_buildinPackageVersion = buildinPackageVersion;
}
/// <summary>
/// 更新流程
/// </summary>
public void Update()
{
if (IsDone)
return;
if (_steps == ESteps.CopyBuildinManifest)
{
string savePath = PersistentHelper.GetCacheManifestFilePath(_buildinPackageName);
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebFileRequester();
_downloader.SendRequest(url, savePath);
_steps = ESteps.CheckCopyBuildinManifest;
}
if (_steps == ESteps.CheckCopyBuildinManifest)
{
if (_downloader.IsDone() == false)
return;
if (_downloader.HasError())
{
Error = _downloader.GetError();
}
_steps = ESteps.Done;
_downloader.Dispose();
}
}
}
/// <summary>
/// 沙盒补丁清单加载器
/// </summary>
internal class CacheManifestLoader
{
private enum ESteps
{
LoadCacheManifestFile,
CheckDeserializeManifest,
Done,
}
private readonly string _packageName;
private ESteps _steps = ESteps.LoadCacheManifestFile;
private DeserializeManifestOperation _deserializer;
private string _manifestFilePath;
/// <summary>
/// 加载结果
/// </summary>
public PatchManifest Manifest { private set; get; }
/// <summary>
/// 加载进度
/// </summary>
public float Progress { private set; get; }
/// <summary>
/// 错误日志
/// </summary>
public string Error { private set; get; }
/// <summary>
/// 是否已经完成
/// </summary>
public bool IsDone
{
get
{
return _steps == ESteps.Done;
}
}
public CacheManifestLoader(string packageName)
{
_packageName = packageName;
}
/// <summary>
/// 更新流程
/// </summary>
public void Update()
{
if (IsDone)
return;
if (_steps == ESteps.LoadCacheManifestFile)
{
_manifestFilePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
if (File.Exists(_manifestFilePath) == false)
{
_steps = ESteps.Done;
Error = $"Manifest file not found : {_manifestFilePath}";
return;
}
byte[] bytesData = File.ReadAllBytes(_manifestFilePath);
_deserializer = new DeserializeManifestOperation(bytesData);
OperationSystem.StartOperation(_deserializer);
_steps = ESteps.CheckDeserializeManifest;
}
if (_steps == ESteps.CheckDeserializeManifest)
{
Progress = _deserializer.Progress;
if (_deserializer.IsDone)
{
if (_deserializer.Status == EOperationStatus.Succeed)
{
Manifest = _deserializer.Manifest;
}
else
{
Error = _deserializer.Error;
// 注意:如果加载沙盒内的清单报错,为了避免流程被卡住,我们主动把损坏的文件删除。
if (File.Exists(_manifestFilePath))
{
YooLogger.Warning($"Failed to load cache manifest file : {Error}");
YooLogger.Warning($"Invalid cache manifest file have been removed : {_manifestFilePath}");
File.Delete(_manifestFilePath);
}
}
_steps = ESteps.Done;
}
}
}
}
} }

View File

@ -10,10 +10,131 @@ namespace YooAsset
/// </summary> /// </summary>
public abstract class UpdatePackageManifestOperation : AsyncOperationBase public abstract class UpdatePackageManifestOperation : AsyncOperationBase
{ {
internal IPlayModeServices _playModeServices;
internal PatchManifest _patchManifest;
/// <summary> /// <summary>
/// 是否发现了新的补丁清单 /// 是否发现了新的补丁清单
/// </summary> /// </summary>
public bool FoundNewManifest { protected set; get; } = false; public bool FoundNewManifest { protected set; get; } = false;
#region 资源下载
/// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
/// </summary>
/// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
return _playModeServices.CreatePatchDownloaderByTags(_patchManifest, new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
/// </summary>
/// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
return _playModeServices.CreatePatchDownloaderByTags(_patchManifest, tags, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
return _playModeServices.CreatePatchDownloaderByAll(_patchManifest, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="assetInfos">资源信息列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
return _playModeServices.CreatePatchDownloaderByPaths(_patchManifest, assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
}
#endregion
#region 资源解压
/// <summary>
/// 创建补丁解压器
/// </summary>
/// <param name="tag">资源标签</param>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param>
public PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call unpacker !");
return PatchUnpackerOperation.CreateEmptyUnpacker(unpackingMaxNumber, failedTryAgain, int.MaxValue);
}
return _playModeServices.CreatePatchUnpackerByTags(_patchManifest, new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
}
/// <summary>
/// 创建补丁解压器
/// </summary>
/// <param name="tags">资源标签列表</param>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param>
public PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call unpacker !");
return PatchUnpackerOperation.CreateEmptyUnpacker(unpackingMaxNumber, failedTryAgain, int.MaxValue);
}
return _playModeServices.CreatePatchUnpackerByTags(_patchManifest, tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
}
/// <summary>
/// 创建补丁解压器
/// </summary>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param>
public PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call unpacker !");
return PatchUnpackerOperation.CreateEmptyUnpacker(unpackingMaxNumber, failedTryAgain, int.MaxValue);
}
return _playModeServices.CreatePatchUnpackerByAll(_patchManifest, unpackingMaxNumber, failedTryAgain, int.MaxValue);
}
#endregion
} }
/// <summary> /// <summary>
@ -21,6 +142,10 @@ namespace YooAsset
/// </summary> /// </summary>
internal sealed class EditorPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation internal sealed class EditorPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
{ {
public EditorPlayModeUpdatePackageManifestOperation(EditorSimulateModeImpl impl)
{
_playModeServices = impl;
}
internal override void Start() internal override void Start()
{ {
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
@ -35,6 +160,10 @@ namespace YooAsset
/// </summary> /// </summary>
internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
{ {
public OfflinePlayModeUpdatePackageManifestOperation(OfflinePlayModeImpl impl)
{
_playModeServices = impl;
}
internal override void Start() internal override void Start()
{ {
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
@ -83,6 +212,7 @@ namespace YooAsset
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout) internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
{ {
_playModeServices = impl;
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_packageVersion = packageVersion; _packageVersion = packageVersion;
@ -141,12 +271,15 @@ namespace YooAsset
if (_cacheManifestHash == webManifestHash) if (_cacheManifestHash == webManifestHash)
{ {
YooLogger.Log($"Not found new package : {_packageName}"); YooLogger.Log($"Not found new package : {_packageName}");
_patchManifest = _impl.ActivePatchManifest;
FoundNewManifest = false;
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
} }
else else
{ {
YooLogger.Log($"Package {_packageName} is change : {_cacheManifestHash} -> {webManifestHash}"); YooLogger.Log($"Package {_packageName} is change : {_cacheManifestHash} -> {webManifestHash}");
FoundNewManifest = true;
_steps = ESteps.DownloadWebManifest; _steps = ESteps.DownloadWebManifest;
} }
} }
@ -210,14 +343,14 @@ namespace YooAsset
_impl.ActivePatchManifest = _deserializer.Manifest; _impl.ActivePatchManifest = _deserializer.Manifest;
} }
FoundNewManifest = true; _patchManifest = _deserializer.Manifest;
_steps = ESteps.StartVerifyOperation; _steps = ESteps.StartVerifyOperation;
} }
else else
{ {
_steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _deserializer.Error; Error = _deserializer.Error;
_steps = ESteps.Done;
} }
} }
} }

View File

@ -61,8 +61,8 @@ namespace YooAsset
private readonly string _packageName; private readonly string _packageName;
private readonly bool _appendTimeTicks; private readonly bool _appendTimeTicks;
private readonly int _timeout; private readonly int _timeout;
private ESteps _steps = ESteps.None;
private UnityWebDataRequester _downloader; private UnityWebDataRequester _downloader;
private ESteps _steps = ESteps.None;
internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, bool appendTimeTicks, int timeout) internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, bool appendTimeTicks, int timeout)
{ {
@ -85,7 +85,7 @@ namespace YooAsset
{ {
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName); string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
string webURL = GetStaticVersionRequestURL(fileName); string webURL = GetStaticVersionRequestURL(fileName);
YooLogger.Log($"Beginning to request static version : {webURL}"); YooLogger.Log($"Beginning to request package version : {webURL}");
_downloader = new UnityWebDataRequester(); _downloader = new UnityWebDataRequester();
_downloader.SendRequest(webURL, _timeout); _downloader.SendRequest(webURL, _timeout);
_steps = ESteps.CheckStaticVersion; _steps = ESteps.CheckStaticVersion;
@ -110,7 +110,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"Static package version is empty : {_downloader.URL}"; Error = $"Package version is empty : {_downloader.URL}";
} }
else else
{ {
@ -118,6 +118,7 @@ namespace YooAsset
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
} }
} }
_downloader.Dispose(); _downloader.Dispose();
} }
} }

View File

@ -54,7 +54,7 @@ namespace YooAsset
} }
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout) UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
{ {
var operation = new EditorPlayModeUpdatePackageManifestOperation(); var operation = new EditorPlayModeUpdatePackageManifestOperation(this);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
@ -65,35 +65,49 @@ namespace YooAsset
return operation; return operation;
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); }
return operation;
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(PatchManifest patchManifest, string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); }
return operation;
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
return operation;
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue); }
return operation;
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(PatchManifest patchManifest, string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
}
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
} }
#endregion #endregion

View File

@ -122,16 +122,22 @@ namespace YooAsset
return operation; return operation;
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = GetDownloadListByAll(); List<BundleInfo> downloadList = GetDownloadListByAll(patchManifest);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
private List<BundleInfo> GetDownloadListByAll() PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = GetDownloadListByAll(_activePatchManifest);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetDownloadListByAll(PatchManifest patchManifest)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in _activePatchManifest.BundleList) foreach (var patchBundle in patchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
@ -147,16 +153,22 @@ namespace YooAsset
return ConvertToDownloadList(downloadList); return ConvertToDownloadList(downloadList);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(PatchManifest patchManifest, string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = GetDownloadListByTags(tags); List<BundleInfo> downloadList = GetDownloadListByTags(patchManifest, tags);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
private List<BundleInfo> GetDownloadListByTags(string[] tags) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = GetDownloadListByTags(_activePatchManifest, tags);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetDownloadListByTags(PatchManifest patchManifest, string[] tags)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in _activePatchManifest.BundleList) foreach (var patchBundle in patchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
@ -184,13 +196,19 @@ namespace YooAsset
return ConvertToDownloadList(downloadList); return ConvertToDownloadList(downloadList);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = GetDownloadListByPaths(assetInfos); List<BundleInfo> downloadList = GetDownloadListByPaths(patchManifest, assetInfos);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
private List<BundleInfo> GetDownloadListByPaths(AssetInfo[] assetInfos) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> downloadList = GetDownloadListByPaths(_activePatchManifest, assetInfos);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetDownloadListByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos)
{ {
// 获取资源对象的资源包和所有依赖资源包 // 获取资源对象的资源包和所有依赖资源包
List<PatchBundle> checkList = new List<PatchBundle>(); List<PatchBundle> checkList = new List<PatchBundle>();
@ -203,12 +221,12 @@ namespace YooAsset
} }
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果补丁清单里未找到资源包会抛出异常!
PatchBundle mainBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath); PatchBundle mainBundle = patchManifest.GetMainPatchBundle(assetInfo.AssetPath);
if (checkList.Contains(mainBundle) == false) if (checkList.Contains(mainBundle) == false)
checkList.Add(mainBundle); checkList.Add(mainBundle);
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果补丁清单里未找到资源包会抛出异常!
PatchBundle[] dependBundles = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath); PatchBundle[] dependBundles = patchManifest.GetAllDependencies(assetInfo.AssetPath);
foreach (var dependBundle in dependBundles) foreach (var dependBundle in dependBundles)
{ {
if (checkList.Contains(dependBundle) == false) if (checkList.Contains(dependBundle) == false)
@ -233,16 +251,52 @@ namespace YooAsset
return ConvertToDownloadList(downloadList); return ConvertToDownloadList(downloadList);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> unpcakList = GetUnpackListByTags(tags); List<BundleInfo> unpcakList = GetUnpackListByAll(patchManifest);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout); var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
private List<BundleInfo> GetUnpackListByTags(string[] tags) PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> unpcakList = GetUnpackListByAll(_activePatchManifest);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetUnpackListByAll(PatchManifest patchManifest)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in _activePatchManifest.BundleList) foreach (var patchBundle in patchManifest.BundleList)
{
// 忽略缓存文件
if (CacheSystem.IsCached(patchBundle))
continue;
if (IsBuildinPatchBundle(patchBundle))
{
downloadList.Add(patchBundle);
}
}
return ConvertToUnpackList(downloadList);
}
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(PatchManifest patchManifest, string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> unpcakList = GetUnpackListByTags(patchManifest, tags);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> unpcakList = GetUnpackListByTags(_activePatchManifest, tags);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetUnpackListByTags(PatchManifest patchManifest, string[] tags)
{
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in patchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
@ -260,30 +314,6 @@ namespace YooAsset
return ConvertToUnpackList(downloadList); return ConvertToUnpackList(downloadList);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{
List<BundleInfo> unpcakList = GetUnpackListByAll();
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetUnpackListByAll()
{
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in _activePatchManifest.BundleList)
{
// 忽略缓存文件
if (CacheSystem.IsCached(patchBundle))
continue;
if (IsBuildinPatchBundle(patchBundle))
{
downloadList.Add(patchBundle);
}
}
return ConvertToUnpackList(downloadList);
}
#endregion #endregion
#region IBundleServices接口 #region IBundleServices接口

View File

@ -54,7 +54,7 @@ namespace YooAsset
} }
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout) UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
{ {
var operation = new OfflinePlayModeUpdatePackageManifestOperation(); var operation = new OfflinePlayModeUpdatePackageManifestOperation(this);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
@ -65,35 +65,49 @@ namespace YooAsset
return operation; return operation;
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); }
return operation;
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(PatchManifest patchManifest, string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); }
return operation;
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout) PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
return operation;
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue); }
return operation;
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(PatchManifest patchManifest, string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
}
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
} }
#endregion #endregion

View File

@ -34,12 +34,17 @@ namespace YooAsset
CheckPackageContentsOperation CheckPackageContentsAsync(); CheckPackageContentsOperation CheckPackageContentsAsync();
// 下载相关方法 // 下载相关方法
PatchDownloaderOperation CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout); PatchDownloaderOperation CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByTags(PatchManifest patchManifest, string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout); PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout); PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
// 解压相关方法 // 解压相关方法
PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout); PatchUnpackerOperation CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout);
PatchUnpackerOperation CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout); PatchUnpackerOperation CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
PatchUnpackerOperation CreatePatchUnpackerByTags(PatchManifest patchManifest, string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
} }
} }

View File

@ -320,19 +320,6 @@ namespace YooAsset
return _defaultPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain); return _defaultPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain);
} }
/// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源定位列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.CreateBundleDownloader(locations, downloadingMaxNumber, failedTryAgain);
}
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件 /// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
/// </summary> /// </summary>