diff --git a/Assets/YooAsset/Runtime/AssetsPackage.cs b/Assets/YooAsset/Runtime/AssetsPackage.cs
index d9c9cb6..6e7fd18 100644
--- a/Assets/YooAsset/Runtime/AssetsPackage.cs
+++ b/Assets/YooAsset/Runtime/AssetsPackage.cs
@@ -663,28 +663,6 @@ namespace YooAsset
return _playModeServices.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
}
-
- ///
- /// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
- ///
- /// 资源定位列表
- /// 同时下载的最大文件数
- /// 下载失败的重试次数
- /// 超时时间
- public PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
- {
- DebugCheckInitialize();
-
- List assetInfos = new List(locations.Length);
- foreach (var location in locations)
- {
- AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
- assetInfos.Add(assetInfo);
- }
-
- return _playModeServices.CreatePatchDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
- }
-
///
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
///
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestCopyOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestCopyOperation.cs
new file mode 100644
index 0000000..90b810f
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestCopyOperation.cs
@@ -0,0 +1,69 @@
+
+namespace YooAsset
+{
+ ///
+ /// 内置补丁清单复制器
+ ///
+ 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();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestCopyOperation.cs.meta
similarity index 83%
rename from Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs.meta
rename to Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestCopyOperation.cs.meta
index 6c362bd..cae3853 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs.meta
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestCopyOperation.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: c4b754a3b15abc44fa2727f57721e18b
+guid: 3a7685e67b0e948439ffba34513b78c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestLoadOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestLoadOperation.cs
new file mode 100644
index 0000000..e1e4120
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestLoadOperation.cs
@@ -0,0 +1,97 @@
+
+namespace YooAsset
+{
+ ///
+ /// 内置补丁清单加载器
+ ///
+ 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;
+
+ ///
+ /// 加载结果
+ ///
+ 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;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestLoadOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestLoadOperation.cs.meta
new file mode 100644
index 0000000..11f55b2
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinManifestLoadOperation.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f3a2fe7d8d4747d43b3ac48097341e36
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinPackageVersionQueryOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinPackageVersionQueryOperation.cs
new file mode 100644
index 0000000..bc8c704
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinPackageVersionQueryOperation.cs
@@ -0,0 +1,81 @@
+
+namespace YooAsset
+{
+ ///
+ /// 内置补丁清单版本查询器
+ ///
+ internal class BuildinPackageVersionQueryOperation : AsyncOperationBase
+ {
+ private enum ESteps
+ {
+ None,
+ LoadPackageVersion,
+ CheckLoadPackageVersion,
+ Done,
+ }
+
+ private readonly string _packageName;
+ private UnityWebDataRequester _downloader;
+ private ESteps _steps = ESteps.None;
+
+ ///
+ /// 内置包裹版本
+ ///
+ 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();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinPackageVersionQueryOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinPackageVersionQueryOperation.cs.meta
new file mode 100644
index 0000000..6430963
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/BuildinPackageVersionQueryOperation.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: bdc251ea99d82e54199dfba540f2814d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/CacheManifestLoadOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/CacheManifestLoadOperation.cs
new file mode 100644
index 0000000..b2f9280
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/CacheManifestLoadOperation.cs
@@ -0,0 +1,88 @@
+using System.IO;
+
+namespace YooAsset
+{
+ ///
+ /// 沙盒补丁清单加载器
+ ///
+ 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;
+
+ ///
+ /// 加载结果
+ ///
+ 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);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/CacheManifestLoadOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/CacheManifestLoadOperation.cs.meta
new file mode 100644
index 0000000..6b4377e
--- /dev/null
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/CacheManifestLoadOperation.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5067db2d5b2aa1240aef2f9a952a2e0c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DeserializeManifestOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DeserializeManifestOperation.cs
index 6371d59..dc27008 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DeserializeManifestOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/DeserializeManifestOperation.cs
@@ -153,6 +153,7 @@ namespace YooAsset
}
catch(System.Exception e)
{
+ Manifest = null;
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = e.Message;
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs
deleted file mode 100644
index 28a4c5e..0000000
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-
-/*
-namespace YooAsset
-{
- public abstract class DownloadPackageOperation : AsyncOperationBase
- {
- ///
- /// 创建包裹下载器
- ///
- /// 同时下载的最大文件数
- /// 下载失败的重试次数
- /// 超时时间(单位:秒)
- public abstract PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout);
- }
-
- ///
- /// 编辑器下模拟运行的更新资源包裹操作
- ///
- internal sealed class EditorPlayModeDownloadPackageOperation : DownloadPackageOperation
- {
- internal override void Start()
- {
- Status = EOperationStatus.Succeed;
- }
- internal override void Update()
- {
- }
-
- ///
- /// 创建包裹下载器
- ///
- public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
- {
- List downloadList = new List();
- var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
- }
- }
-
- ///
- /// 离线模式的更新资源包裹操作
- ///
- internal sealed class OfflinePlayModeDownloadPackageOperation : DownloadPackageOperation
- {
- internal override void Start()
- {
- Status = EOperationStatus.Succeed;
- }
- internal override void Update()
- {
- }
-
- ///
- /// 创建包裹下载器
- ///
- public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
- {
- List downloadList = new List();
- var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
- }
- }
-
- ///
- /// 联机模式的更新资源包裹操作
- ///
- 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;
- }
- }
- }
- }
-
- ///
- /// 创建包裹下载器
- ///
- public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
- {
- if (Status == EOperationStatus.Succeed)
- {
- YooLogger.Log($"Create package downloader : {_remotePatchManifest.PackageName} {_remotePatchManifest.PackageVersion}");
- List 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;
- }
- }
-
- ///
- /// 获取补丁清单请求地址
- ///
- private string GetPatchManifestRequestURL(string fileName)
- {
- // 轮流返回请求地址
- if (RequestCount % 2 == 0)
- return _impl.GetPatchDownloadFallbackURL(fileName);
- else
- return _impl.GetPatchDownloadMainURL(fileName);
- }
-
- ///
- /// 获取下载列表
- ///
- private List GetDownloadList()
- {
- List downloadList = new List(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);
- }
- }
-}
-*/
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs
index feb1e86..100b4bd 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloaderOperation.cs
@@ -19,7 +19,7 @@ namespace YooAsset
public delegate void OnDownloadProgress(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes);
public delegate void OnDownloadError(string fileName, string error);
public delegate void OnStartDownloadFile(string fileName, long sizeBytes);
-
+
private readonly int _downloadingMaxNumber;
private readonly int _failedTryAgain;
private readonly int _timeout;
@@ -74,7 +74,7 @@ namespace YooAsset
/// 当开始下载某个文件
///
public OnStartDownloadFile OnStartDownloadFileCallback { set; get; }
-
+
internal DownloaderOperation(List downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
@@ -183,9 +183,9 @@ namespace YooAsset
{
var failedDownloader = _failedList[0];
string fileName = failedDownloader.GetBundleInfo().Bundle.BundleName;
- Error = $"Failed to download file : {fileName}";
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
+ Error = $"Failed to download file : {fileName}";
OnDownloadErrorCallback?.Invoke(fileName, failedDownloader.GetLastError());
OnDownloadOverCallback?.Invoke(false);
}
@@ -241,19 +241,22 @@ namespace YooAsset
}
}
- public sealed class PackageDownloaderOperation : DownloaderOperation
- {
- internal PackageDownloaderOperation(List downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
- : base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
- {
- }
- }
public sealed class PatchDownloaderOperation : DownloaderOperation
{
internal PatchDownloaderOperation(List downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{
}
+
+ ///
+ /// 创建空的下载器
+ ///
+ internal static PatchDownloaderOperation CreateEmptyDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List downloadList = new List();
+ var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
}
public sealed class PatchUnpackerOperation : DownloaderOperation
{
@@ -261,5 +264,15 @@ namespace YooAsset
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{
}
+
+ ///
+ /// 创建空的解压器
+ ///
+ internal static PatchUnpackerOperation CreateEmptyUnpacker(int upackingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List downloadList = new List();
+ var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
+ return operation;
+ }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs
index d3a8076..53559fe 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs
@@ -64,22 +64,21 @@ namespace YooAsset
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 = manifest.PackageVersion;
- _impl.ActivePatchManifest = manifest;
- _steps = ESteps.Done;
- Status = EOperationStatus.Succeed;
- }
- else
- {
- _steps = ESteps.Done;
- Status = EOperationStatus.Failed;
- Error = _deserializer.Error;
- }
+ InitializedPackageVersion = _deserializer.Manifest.PackageVersion;
+ _impl.ActivePatchManifest = _deserializer.Manifest;
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Succeed;
+ }
+ else
+ {
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Failed;
+ Error = _deserializer.Error;
}
}
}
@@ -102,8 +101,8 @@ namespace YooAsset
private readonly OfflinePlayModeImpl _impl;
private readonly string _packageName;
- private readonly BuildinPackageVersionQuerier _buildinPackageVersionQuerier;
- private BuildinManifestLoader _buildinManifestLoader;
+ private BuildinPackageVersionQueryOperation _buildinPackageVersionQuery;
+ private BuildinManifestLoadOperation _buildinManifestLoad;
private CacheFilesVerifyOperation _verifyOperation;
private ESteps _steps = ESteps.None;
private float _verifyTime;
@@ -112,7 +111,7 @@ namespace YooAsset
{
_impl = impl;
_packageName = packageName;
- _buildinPackageVersionQuerier = new BuildinPackageVersionQuerier(packageName);
+
}
internal override void Start()
{
@@ -125,43 +124,50 @@ namespace YooAsset
if (_steps == ESteps.QueryBuildinPackageVersion)
{
- _buildinPackageVersionQuerier.Update();
- if (_buildinPackageVersionQuerier.IsDone == false)
+ if (_buildinPackageVersionQuery == null)
+ {
+ _buildinPackageVersionQuery = new BuildinPackageVersionQueryOperation(_packageName);
+ OperationSystem.StartOperation(_buildinPackageVersionQuery);
+ }
+
+ if (_buildinPackageVersionQuery.IsDone == false)
return;
- string error = _buildinPackageVersionQuerier.Error;
- if (string.IsNullOrEmpty(error) == false)
+ if (_buildinPackageVersionQuery.Status == EOperationStatus.Succeed)
{
- _steps = ESteps.Done;
- Status = EOperationStatus.Failed;
- Error = error;
+ _steps = ESteps.LoadBuildinManifest;
}
else
{
- _buildinManifestLoader = new BuildinManifestLoader(_packageName, _buildinPackageVersionQuerier.Version);
- _steps = ESteps.LoadBuildinManifest;
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Failed;
+ Error = _buildinPackageVersionQuery.Error;
}
}
if (_steps == ESteps.LoadBuildinManifest)
{
- _buildinManifestLoader.Update();
- Progress = _buildinManifestLoader.Progress;
- if (_buildinManifestLoader.IsDone == false)
+ if (_buildinManifestLoad == null)
+ {
+ _buildinManifestLoad = new BuildinManifestLoadOperation(_packageName, _buildinPackageVersionQuery.Version);
+ OperationSystem.StartOperation(_buildinManifestLoad);
+ }
+
+ Progress = _buildinManifestLoad.Progress;
+ if (_buildinManifestLoad.IsDone == false)
return;
- var manifest = _buildinManifestLoader.Manifest;
- if (manifest == null)
+ if (_buildinManifestLoad.Status == EOperationStatus.Succeed)
{
- _steps = ESteps.Done;
- Status = EOperationStatus.Failed;
- Error = _buildinManifestLoader.Error;
+ InitializedPackageVersion = _buildinManifestLoad.Manifest.PackageVersion;
+ _impl.ActivePatchManifest = _buildinManifestLoad.Manifest;
+ _steps = ESteps.StartVerifyOperation;
}
else
{
- InitializedPackageVersion = manifest.PackageVersion;
- _impl.ActivePatchManifest = manifest;
- _steps = ESteps.StartVerifyOperation;
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Failed;
+ Error = _buildinManifestLoad.Error;
}
}
@@ -213,10 +219,10 @@ namespace YooAsset
private readonly HostPlayModeImpl _impl;
private readonly string _packageName;
- private readonly BuildinPackageVersionQuerier _buildinPackageVersionQuerier;
- private BuildinManifestCopyer _buildinManifestCopyer;
- private BuildinManifestLoader _buildinManifestLoader;
- private CacheManifestLoader _cacheManifestLoader;
+ private BuildinPackageVersionQueryOperation _buildinPackageVersionQuery;
+ private BuildinManifestCopyOperation _buildinManifestCopy;
+ private BuildinManifestLoadOperation _buildinManifestLoad;
+ private CacheManifestLoadOperation _cacheManifestLoad;
private CacheFilesVerifyOperation _verifyOperation;
private ESteps _steps = ESteps.None;
private float _verifyTime;
@@ -225,7 +231,6 @@ namespace YooAsset
{
_impl = impl;
_packageName = packageName;
- _buildinPackageVersionQuerier = new BuildinPackageVersionQuerier(packageName);
}
internal override void Start()
{
@@ -253,87 +258,99 @@ namespace YooAsset
if (_steps == ESteps.TryLoadCacheManifest)
{
- if (_cacheManifestLoader == null)
- _cacheManifestLoader = new CacheManifestLoader(_packageName);
-
- _cacheManifestLoader.Update();
- if (_cacheManifestLoader.IsDone)
+ if (_cacheManifestLoad == null)
{
- var manifest = _cacheManifestLoader.Manifest;
- if (manifest != null)
- {
- InitializedPackageVersion = manifest.PackageVersion;
- _impl.ActivePatchManifest = manifest;
- _steps = ESteps.StartVerifyOperation;
- }
- else
- {
- _steps = ESteps.QueryBuildinPackageVersion;
- }
+ _cacheManifestLoad = new CacheManifestLoadOperation(_packageName);
+ OperationSystem.StartOperation(_cacheManifestLoad);
+ }
+
+ if (_cacheManifestLoad.IsDone == false)
+ return;
+
+ if (_cacheManifestLoad.Status == EOperationStatus.Succeed)
+ {
+ InitializedPackageVersion = _cacheManifestLoad.Manifest.PackageVersion;
+ _impl.ActivePatchManifest = _cacheManifestLoad.Manifest;
+ _steps = ESteps.StartVerifyOperation;
+ }
+ else
+ {
+ _steps = ESteps.QueryBuildinPackageVersion;
}
}
if (_steps == ESteps.QueryBuildinPackageVersion)
{
- _buildinPackageVersionQuerier.Update();
- if (_buildinPackageVersionQuerier.IsDone == false)
+ if (_buildinPackageVersionQuery == null)
+ {
+ _buildinPackageVersionQuery = new BuildinPackageVersionQueryOperation(_packageName);
+ OperationSystem.StartOperation(_buildinPackageVersionQuery);
+ }
+
+ if (_buildinPackageVersionQuery.IsDone == false)
return;
// 注意:为了兼容MOD模式,初始化动态新增的包裹的时候,如果内置清单不存在也不需要报错!
- string error = _buildinPackageVersionQuerier.Error;
- if (string.IsNullOrEmpty(error) == false)
+ if (_buildinPackageVersionQuery.Status == EOperationStatus.Succeed)
{
- _steps = ESteps.Done;
- Status = EOperationStatus.Succeed;
- YooLogger.Log($"Failed to load buildin package version file : {error}");
+ _steps = ESteps.CopyBuildinManifest;
}
else
{
- _buildinManifestCopyer = new BuildinManifestCopyer(_packageName, _buildinPackageVersionQuerier.Version);
- _buildinManifestLoader = new BuildinManifestLoader(_packageName, _buildinPackageVersionQuerier.Version);
- _steps = ESteps.CopyBuildinManifest;
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Succeed;
+ string error = _buildinPackageVersionQuery.Error;
+ YooLogger.Log($"Failed to load buildin package version file : {error}");
}
}
if (_steps == ESteps.CopyBuildinManifest)
{
- _buildinManifestCopyer.Update();
- Progress = _buildinManifestCopyer.Progress;
- if (_buildinManifestCopyer.IsDone == false)
+ if (_buildinManifestCopy == null)
+ {
+ _buildinManifestCopy = new BuildinManifestCopyOperation(_packageName, _buildinPackageVersionQuery.Version);
+ OperationSystem.StartOperation(_buildinManifestCopy);
+ }
+
+ Progress = _buildinManifestCopy.Progress;
+ if (_buildinManifestCopy.IsDone == false)
return;
- string error = _buildinManifestCopyer.Error;
- if (string.IsNullOrEmpty(error) == false)
+ if (_buildinManifestCopy.Status == EOperationStatus.Succeed)
{
- _steps = ESteps.Done;
- Status = EOperationStatus.Failed;
- Error = error;
+ _steps = ESteps.LoadBuildinManifest;
}
else
{
- _steps = ESteps.LoadBuildinManifest;
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Failed;
+ Error = _buildinManifestCopy.Error;
}
}
if (_steps == ESteps.LoadBuildinManifest)
{
- _buildinManifestLoader.Update();
- Progress = _buildinManifestLoader.Progress;
- if (_buildinManifestLoader.IsDone == false)
+ if (_buildinManifestLoad == null)
+ {
+ _buildinManifestLoad = new BuildinManifestLoadOperation(_packageName, _buildinPackageVersionQuery.Version);
+ OperationSystem.StartOperation(_buildinManifestLoad);
+ }
+
+ Progress = _buildinManifestLoad.Progress;
+ if (_buildinManifestLoad.IsDone == false)
return;
- var manifest = _buildinManifestLoader.Manifest;
- if (manifest == null)
- {
- _steps = ESteps.Done;
- Status = EOperationStatus.Failed;
- Error = _buildinManifestLoader.Error;
+ if (_buildinManifestLoad.Status == EOperationStatus.Succeed)
+ {
+ InitializedPackageVersion = _buildinManifestLoad.Manifest.PackageVersion;
+ _impl.ActivePatchManifest = _buildinManifestLoad.Manifest;
+ _steps = ESteps.StartVerifyOperation;
}
else
{
- InitializedPackageVersion = manifest.PackageVersion;
- _impl.ActivePatchManifest = manifest;
- _steps = ESteps.StartVerifyOperation;
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Failed;
+ Error = _buildinManifestLoad.Error;
}
}
@@ -415,383 +432,4 @@ namespace YooAsset
YooLogger.Log($"Save application foot print : {_footPrint}");
}
}
-
- ///
- /// 内置补丁清单版本查询器
- ///
- internal class BuildinPackageVersionQuerier
- {
- private enum ESteps
- {
- LoadStaticVersion,
- CheckStaticVersion,
- Done,
- }
-
- private readonly string _buildinPackageName;
- private ESteps _steps = ESteps.LoadStaticVersion;
- private UnityWebDataRequester _downloader;
-
- ///
- /// 内置包裹版本
- ///
- public string Version { private set; get; }
-
- ///
- /// 错误日志
- ///
- public string Error { private set; get; }
-
- ///
- /// 是否已经完成
- ///
- public bool IsDone
- {
- get
- {
- return _steps == ESteps.Done;
- }
- }
-
-
- public BuildinPackageVersionQuerier(string buildinPackageName)
- {
- _buildinPackageName = buildinPackageName;
- }
-
- ///
- /// 更新流程
- ///
- 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();
- }
- }
- }
-
- ///
- /// 内置补丁清单加载器
- ///
- 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;
-
- ///
- /// 加载结果
- ///
- public PatchManifest Manifest { private set; get; }
-
- ///
- /// 加载进度
- ///
- public float Progress { private set; get; }
-
- ///
- /// 错误日志
- ///
- public string Error { private set; get; }
-
- ///
- /// 是否已经完成
- ///
- public bool IsDone
- {
- get
- {
- return _steps == ESteps.Done;
- }
- }
-
-
- public BuildinManifestLoader(string buildinPackageName, string buildinPackageVersion)
- {
- _buildinPackageName = buildinPackageName;
- _buildinPackageVersion = buildinPackageVersion;
- }
-
- ///
- /// 更新流程
- ///
- 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;
- }
- }
- }
- }
-
- ///
- /// 内置补丁清单复制器
- ///
- 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;
-
- ///
- /// 错误日志
- ///
- public string Error { private set; get; }
-
- ///
- /// 是否已经完成
- ///
- public bool IsDone
- {
- get
- {
- return _steps == ESteps.Done;
- }
- }
-
- ///
- /// 加载进度
- ///
- public float Progress
- {
- get
- {
- if (_downloader == null)
- return 0;
- return _downloader.Progress();
- }
- }
-
-
- public BuildinManifestCopyer(string buildinPackageName, string buildinPackageVersion)
- {
- _buildinPackageName = buildinPackageName;
- _buildinPackageVersion = buildinPackageVersion;
- }
-
- ///
- /// 更新流程
- ///
- 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();
- }
- }
- }
-
- ///
- /// 沙盒补丁清单加载器
- ///
- internal class CacheManifestLoader
- {
- private enum ESteps
- {
- LoadCacheManifestFile,
- CheckDeserializeManifest,
- Done,
- }
-
- private readonly string _packageName;
- private ESteps _steps = ESteps.LoadCacheManifestFile;
- private DeserializeManifestOperation _deserializer;
- private string _manifestFilePath;
-
- ///
- /// 加载结果
- ///
- public PatchManifest Manifest { private set; get; }
-
- ///
- /// 加载进度
- ///
- public float Progress { private set; get; }
-
- ///
- /// 错误日志
- ///
- public string Error { private set; get; }
-
- ///
- /// 是否已经完成
- ///
- public bool IsDone
- {
- get
- {
- return _steps == ESteps.Done;
- }
- }
-
-
- public CacheManifestLoader(string packageName)
- {
- _packageName = packageName;
- }
-
- ///
- /// 更新流程
- ///
- 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;
- }
- }
- }
- }
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs
index 36a7e24..3898513 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs
@@ -10,10 +10,131 @@ namespace YooAsset
///
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
{
+ internal IPlayModeServices _playModeServices;
+ internal PatchManifest _patchManifest;
+
///
/// 是否发现了新的补丁清单
///
public bool FoundNewManifest { protected set; get; } = false;
+
+ #region 资源下载
+ ///
+ /// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
+ ///
+ /// 资源标签
+ /// 同时下载的最大文件数
+ /// 下载失败的重试次数
+ /// 超时时间
+ 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);
+ }
+
+ ///
+ /// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
+ ///
+ /// 资源标签列表
+ /// 同时下载的最大文件数
+ /// 下载失败的重试次数
+ /// 超时时间
+ 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);
+ }
+
+ ///
+ /// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件
+ ///
+ /// 同时下载的最大文件数
+ /// 下载失败的重试次数
+ /// 超时时间
+ 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);
+ }
+
+ ///
+ /// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
+ ///
+ /// 资源信息列表
+ /// 同时下载的最大文件数
+ /// 下载失败的重试次数
+ /// 超时时间
+ 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 资源解压
+ ///
+ /// 创建补丁解压器
+ ///
+ /// 资源标签
+ /// 同时解压的最大文件数
+ /// 解压失败的重试次数
+ 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);
+ }
+
+ ///
+ /// 创建补丁解压器
+ ///
+ /// 资源标签列表
+ /// 同时解压的最大文件数
+ /// 解压失败的重试次数
+ 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);
+ }
+
+ ///
+ /// 创建补丁解压器
+ ///
+ /// 同时解压的最大文件数
+ /// 解压失败的重试次数
+ 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
}
///
@@ -21,6 +142,10 @@ namespace YooAsset
///
internal sealed class EditorPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
{
+ public EditorPlayModeUpdatePackageManifestOperation(EditorSimulateModeImpl impl)
+ {
+ _playModeServices = impl;
+ }
internal override void Start()
{
Status = EOperationStatus.Succeed;
@@ -35,6 +160,10 @@ namespace YooAsset
///
internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
{
+ public OfflinePlayModeUpdatePackageManifestOperation(OfflinePlayModeImpl impl)
+ {
+ _playModeServices = impl;
+ }
internal override void Start()
{
Status = EOperationStatus.Succeed;
@@ -83,6 +212,7 @@ namespace YooAsset
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
{
+ _playModeServices = impl;
_impl = impl;
_packageName = packageName;
_packageVersion = packageVersion;
@@ -104,7 +234,7 @@ namespace YooAsset
{
string filePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
if (File.Exists(filePath))
- {
+ {
_cacheManifestHash = HashUtility.FileMD5(filePath);
_steps = ESteps.DownloadWebHash;
}
@@ -141,12 +271,15 @@ namespace YooAsset
if (_cacheManifestHash == webManifestHash)
{
YooLogger.Log($"Not found new package : {_packageName}");
+ _patchManifest = _impl.ActivePatchManifest;
+ FoundNewManifest = false;
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
YooLogger.Log($"Package {_packageName} is change : {_cacheManifestHash} -> {webManifestHash}");
+ FoundNewManifest = true;
_steps = ESteps.DownloadWebManifest;
}
}
@@ -210,14 +343,14 @@ namespace YooAsset
_impl.ActivePatchManifest = _deserializer.Manifest;
}
- FoundNewManifest = true;
+ _patchManifest = _deserializer.Manifest;
_steps = ESteps.StartVerifyOperation;
}
else
{
- Status = EOperationStatus.Failed;
- Error = _deserializer.Error;
_steps = ESteps.Done;
+ Status = EOperationStatus.Failed;
+ Error = _deserializer.Error;
}
}
}
diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs
index 9ece186..959c792 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs
@@ -61,13 +61,13 @@ namespace YooAsset
private readonly string _packageName;
private readonly bool _appendTimeTicks;
private readonly int _timeout;
- private ESteps _steps = ESteps.None;
private UnityWebDataRequester _downloader;
+ private ESteps _steps = ESteps.None;
internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, bool appendTimeTicks, int timeout)
{
_impl = impl;
- _packageName = packageName;
+ _packageName = packageName;
_appendTimeTicks = appendTimeTicks;
_timeout = timeout;
}
@@ -85,7 +85,7 @@ namespace YooAsset
{
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
string webURL = GetStaticVersionRequestURL(fileName);
- YooLogger.Log($"Beginning to request static version : {webURL}");
+ YooLogger.Log($"Beginning to request package version : {webURL}");
_downloader = new UnityWebDataRequester();
_downloader.SendRequest(webURL, _timeout);
_steps = ESteps.CheckStaticVersion;
@@ -110,7 +110,7 @@ namespace YooAsset
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
- Error = $"Static package version is empty : {_downloader.URL}";
+ Error = $"Package version is empty : {_downloader.URL}";
}
else
{
@@ -118,6 +118,7 @@ namespace YooAsset
Status = EOperationStatus.Succeed;
}
}
+
_downloader.Dispose();
}
}
diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs
index 7fbf841..d19ae19 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs
@@ -54,7 +54,7 @@ namespace YooAsset
}
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
{
- var operation = new EditorPlayModeUpdatePackageManifestOperation();
+ var operation = new EditorPlayModeUpdatePackageManifestOperation(this);
OperationSystem.StartOperation(operation);
return operation;
}
@@ -65,35 +65,49 @@ namespace YooAsset
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)
{
- List downloadList = new List();
- var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
+ return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
+ }
+
+ 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)
{
- List downloadList = new List();
- var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
+ return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
+ }
+
+ 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)
{
- List downloadList = new List();
- var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
+ return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
- PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
+
+ PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
{
- List downloadList = new List();
- var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
- return operation;
+ return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
}
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{
- List downloadList = new List();
- var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
- return operation;
+ return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
+ }
+
+ 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
diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs
index 5d03707..177cd90 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs
@@ -122,16 +122,22 @@ namespace YooAsset
return operation;
}
- PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
+ PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
- List downloadList = GetDownloadListByAll();
+ List downloadList = GetDownloadListByAll(patchManifest);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
- private List GetDownloadListByAll()
+ PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List downloadList = GetDownloadListByAll(_activePatchManifest);
+ var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetDownloadListByAll(PatchManifest patchManifest)
{
List downloadList = new List(1000);
- foreach (var patchBundle in _activePatchManifest.BundleList)
+ foreach (var patchBundle in patchManifest.BundleList)
{
// 忽略缓存文件
if (CacheSystem.IsCached(patchBundle))
@@ -147,16 +153,22 @@ namespace YooAsset
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 downloadList = GetDownloadListByTags(tags);
+ List downloadList = GetDownloadListByTags(patchManifest, tags);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
- private List GetDownloadListByTags(string[] tags)
+ PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List downloadList = GetDownloadListByTags(_activePatchManifest, tags);
+ var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetDownloadListByTags(PatchManifest patchManifest, string[] tags)
{
List downloadList = new List(1000);
- foreach (var patchBundle in _activePatchManifest.BundleList)
+ foreach (var patchBundle in patchManifest.BundleList)
{
// 忽略缓存文件
if (CacheSystem.IsCached(patchBundle))
@@ -184,13 +196,19 @@ namespace YooAsset
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 downloadList = GetDownloadListByPaths(assetInfos);
+ List downloadList = GetDownloadListByPaths(patchManifest, assetInfos);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
- private List GetDownloadListByPaths(AssetInfo[] assetInfos)
+ PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List downloadList = GetDownloadListByPaths(_activePatchManifest, assetInfos);
+ var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetDownloadListByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos)
{
// 获取资源对象的资源包和所有依赖资源包
List checkList = new List();
@@ -203,12 +221,12 @@ namespace YooAsset
}
// 注意:如果补丁清单里未找到资源包会抛出异常!
- PatchBundle mainBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
+ PatchBundle mainBundle = patchManifest.GetMainPatchBundle(assetInfo.AssetPath);
if (checkList.Contains(mainBundle) == false)
checkList.Add(mainBundle);
// 注意:如果补丁清单里未找到资源包会抛出异常!
- PatchBundle[] dependBundles = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath);
+ PatchBundle[] dependBundles = patchManifest.GetAllDependencies(assetInfo.AssetPath);
foreach (var dependBundle in dependBundles)
{
if (checkList.Contains(dependBundle) == false)
@@ -233,16 +251,52 @@ namespace YooAsset
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 unpcakList = GetUnpackListByTags(tags);
+ List unpcakList = GetUnpackListByAll(patchManifest);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
- private List GetUnpackListByTags(string[] tags)
+ PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List unpcakList = GetUnpackListByAll(_activePatchManifest);
+ var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetUnpackListByAll(PatchManifest patchManifest)
{
List downloadList = new List(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 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 unpcakList = GetUnpackListByTags(_activePatchManifest, tags);
+ var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetUnpackListByTags(PatchManifest patchManifest, string[] tags)
+ {
+ List downloadList = new List(1000);
+ foreach (var patchBundle in patchManifest.BundleList)
{
// 忽略缓存文件
if (CacheSystem.IsCached(patchBundle))
@@ -260,30 +314,6 @@ namespace YooAsset
return ConvertToUnpackList(downloadList);
}
-
- PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
- {
- List unpcakList = GetUnpackListByAll();
- var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
- return operation;
- }
- private List GetUnpackListByAll()
- {
- List downloadList = new List(1000);
- foreach (var patchBundle in _activePatchManifest.BundleList)
- {
- // 忽略缓存文件
- if (CacheSystem.IsCached(patchBundle))
- continue;
-
- if (IsBuildinPatchBundle(patchBundle))
- {
- downloadList.Add(patchBundle);
- }
- }
-
- return ConvertToUnpackList(downloadList);
- }
#endregion
#region IBundleServices接口
diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs
index 9c87fce..7305629 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs
@@ -21,7 +21,7 @@ namespace YooAsset
OperationSystem.StartOperation(operation);
return operation;
}
-
+
#region IPlayModeServices接口
public PatchManifest ActivePatchManifest
{
@@ -54,7 +54,7 @@ namespace YooAsset
}
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
{
- var operation = new OfflinePlayModeUpdatePackageManifestOperation();
+ var operation = new OfflinePlayModeUpdatePackageManifestOperation(this);
OperationSystem.StartOperation(operation);
return operation;
}
@@ -65,35 +65,49 @@ namespace YooAsset
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)
{
- List downloadList = new List();
- var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
+ return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
+ }
+
+ 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)
{
- List downloadList = new List();
- var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
+ return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
+ }
+
+ 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)
{
- List downloadList = new List();
- var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
- return operation;
+ return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
- PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
+
+ PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
{
- List downloadList = new List();
- var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
- return operation;
+ return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
}
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{
- List downloadList = new List();
- var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
- return operation;
+ return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
+ }
+
+ 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
diff --git a/Assets/YooAsset/Runtime/Services/IPlayModeServices.cs b/Assets/YooAsset/Runtime/Services/IPlayModeServices.cs
index 287a30b..8c65125 100644
--- a/Assets/YooAsset/Runtime/Services/IPlayModeServices.cs
+++ b/Assets/YooAsset/Runtime/Services/IPlayModeServices.cs
@@ -34,12 +34,17 @@ namespace YooAsset
CheckPackageContentsOperation CheckPackageContentsAsync();
// 下载相关方法
+ PatchDownloaderOperation CreatePatchDownloaderByAll(PatchManifest patchManifest, 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 CreatePatchDownloaderByPaths(PatchManifest patchManifest, 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 CreatePatchUnpackerByTags(PatchManifest patchManifest, string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
+ PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/YooAssetsExtension.cs b/Assets/YooAsset/Runtime/YooAssetsExtension.cs
index 9f9a815..c4b2fd0 100644
--- a/Assets/YooAsset/Runtime/YooAssetsExtension.cs
+++ b/Assets/YooAsset/Runtime/YooAssetsExtension.cs
@@ -320,19 +320,6 @@ namespace YooAsset
return _defaultPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain);
}
-
- ///
- /// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
- ///
- /// 资源定位列表
- /// 同时下载的最大文件数
- /// 下载失败的重试次数
- public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
- {
- DebugCheckDefaultPackageValid();
- return _defaultPackage.CreateBundleDownloader(locations, downloadingMaxNumber, failedTryAgain);
- }
-
///
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
///