parent
47af58bb5b
commit
ce70eebda6
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class InstantiateOperation : AsyncOperationBase
|
public sealed class InstantiateOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 场景卸载异步操作类
|
/// 场景卸载异步操作类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UnloadSceneOperation : AsyncOperationBase
|
public sealed class UnloadSceneOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum EFlag
|
private enum EFlag
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,14 +77,14 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 异步编程相关
|
#region 异步编程相关
|
||||||
public bool MoveNext()
|
bool IEnumerator.MoveNext()
|
||||||
{
|
{
|
||||||
return !IsDone;
|
return !IsDone;
|
||||||
}
|
}
|
||||||
public void Reset()
|
void IEnumerator.Reset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public object Current => null;
|
object IEnumerator.Current => null;
|
||||||
|
|
||||||
private TaskCompletionSource<object> _taskCompletionSource;
|
private TaskCompletionSource<object> _taskCompletionSource;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -3,11 +3,12 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class DownloaderOperation : AsyncOperationBase
|
public abstract class DownloaderOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
Check,
|
||||||
Loading,
|
Loading,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
@ -17,8 +18,8 @@ namespace YooAsset
|
||||||
public delegate void OnDownloadOver(bool isSucceed);
|
public delegate void OnDownloadOver(bool isSucceed);
|
||||||
public delegate void OnDownloadProgress(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes);
|
public delegate void OnDownloadProgress(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes);
|
||||||
public delegate void OnDownloadFileFailed(string fileName);
|
public delegate void OnDownloadFileFailed(string fileName);
|
||||||
|
|
||||||
private readonly int _fileLoadingMaxNumber;
|
private readonly int _downloadingMaxNumber;
|
||||||
private readonly int _failedTryAgain;
|
private readonly int _failedTryAgain;
|
||||||
private readonly List<BundleInfo> _downloadList;
|
private readonly List<BundleInfo> _downloadList;
|
||||||
private readonly List<BundleInfo> _loadFailedList = new List<BundleInfo>();
|
private readonly List<BundleInfo> _loadFailedList = new List<BundleInfo>();
|
||||||
|
@ -67,28 +68,45 @@ namespace YooAsset
|
||||||
public OnDownloadFileFailed OnDownloadFileFailedCallback { set; get; }
|
public OnDownloadFileFailed OnDownloadFileFailedCallback { set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal DownloaderOperation(List<BundleInfo> downloadList, int fileLoadingMaxNumber, int failedTryAgain)
|
internal DownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
_downloadList = downloadList;
|
_downloadList = downloadList;
|
||||||
_fileLoadingMaxNumber = UnityEngine.Mathf.Clamp(fileLoadingMaxNumber, 1, MAX_LOADER_COUNT); ;
|
_downloadingMaxNumber = UnityEngine.Mathf.Clamp(downloadingMaxNumber, 1, MAX_LOADER_COUNT); ;
|
||||||
_failedTryAgain = failedTryAgain;
|
_failedTryAgain = failedTryAgain;
|
||||||
|
|
||||||
TotalDownloadCount = downloadList.Count;
|
if (downloadList != null)
|
||||||
foreach (var patchBundle in downloadList)
|
|
||||||
{
|
{
|
||||||
TotalDownloadBytes += patchBundle.SizeBytes;
|
TotalDownloadCount = downloadList.Count;
|
||||||
|
foreach (var patchBundle in downloadList)
|
||||||
|
{
|
||||||
|
TotalDownloadBytes += patchBundle.SizeBytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
|
YooLogger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
|
||||||
_steps = ESteps.Loading;
|
_steps = ESteps.Check;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.Check)
|
||||||
|
{
|
||||||
|
if (_downloadList == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Download list is null.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Loading;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
// 检测下载器结果
|
// 检测下载器结果
|
||||||
|
@ -134,7 +152,7 @@ namespace YooAsset
|
||||||
// 注意:如果期间有下载失败的文件,暂停动态创建下载器
|
// 注意:如果期间有下载失败的文件,暂停动态创建下载器
|
||||||
if (_downloadList.Count > 0 && _loadFailedList.Count == 0)
|
if (_downloadList.Count > 0 && _loadFailedList.Count == 0)
|
||||||
{
|
{
|
||||||
if (_downloaders.Count < _fileLoadingMaxNumber)
|
if (_downloaders.Count < _downloadingMaxNumber)
|
||||||
{
|
{
|
||||||
int index = _downloadList.Count - 1;
|
int index = _downloadList.Count - 1;
|
||||||
var operation = DownloadSystem.BeginDownload(_downloadList[index], _failedTryAgain);
|
var operation = DownloadSystem.BeginDownload(_downloadList[index], _failedTryAgain);
|
||||||
|
@ -177,4 +195,26 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class PackageDownloaderOperation : DownloaderOperation
|
||||||
|
{
|
||||||
|
internal PackageDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||||
|
: base(downloadList, downloadingMaxNumber, failedTryAgain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public sealed class PatchDownloaderOperation : DownloaderOperation
|
||||||
|
{
|
||||||
|
internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||||
|
: base(downloadList, downloadingMaxNumber, failedTryAgain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public sealed class PatchUnpackerOperation : DownloaderOperation
|
||||||
|
{
|
||||||
|
internal PatchUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||||
|
: base(downloadList, downloadingMaxNumber, failedTryAgain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -53,24 +53,24 @@ namespace YooAsset
|
||||||
CheckWebManifestHash,
|
CheckWebManifestHash,
|
||||||
LoadWebManifest,
|
LoadWebManifest,
|
||||||
CheckWebManifest,
|
CheckWebManifest,
|
||||||
InitPrepareCache,
|
InitVerifyingCache,
|
||||||
UpdatePrepareCache,
|
UpdateVerifyingCache,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
private static int RequestCount = 0;
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly int _updateResourceVersion;
|
private readonly int _resourceVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloaderHash;
|
private UnityWebDataRequester _downloaderHash;
|
||||||
private UnityWebDataRequester _downloaderManifest;
|
private UnityWebDataRequester _downloaderManifest;
|
||||||
private float _verifyTime;
|
private float _verifyTime;
|
||||||
|
|
||||||
public HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, int updateResourceVersion, int timeout)
|
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, int resourceVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_updateResourceVersion = updateResourceVersion;
|
_resourceVersion = resourceVersion;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
|
@ -85,7 +85,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadWebManifestHash)
|
if (_steps == ESteps.LoadWebManifestHash)
|
||||||
{
|
{
|
||||||
string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestHashFileName(_updateResourceVersion));
|
string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestHashFileName(_resourceVersion));
|
||||||
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
|
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
|
||||||
_downloaderHash = new UnityWebDataRequester();
|
_downloaderHash = new UnityWebDataRequester();
|
||||||
_downloaderHash.SendRequest(webURL, _timeout);
|
_downloaderHash.SendRequest(webURL, _timeout);
|
||||||
|
@ -107,14 +107,14 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string webManifestHash = _downloaderHash.GetText();
|
string webManifestHash = _downloaderHash.GetText();
|
||||||
string cachedManifestHash = GetSandboxPatchManifestFileHash(_updateResourceVersion);
|
string cachedManifestHash = GetSandboxPatchManifestFileHash(_resourceVersion);
|
||||||
|
|
||||||
// 如果补丁清单文件的哈希值相同
|
// 如果补丁清单文件的哈希值相同
|
||||||
if (cachedManifestHash == webManifestHash)
|
if (cachedManifestHash == webManifestHash)
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
|
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
|
||||||
LoadSandboxPatchManifest(_updateResourceVersion);
|
LoadSandboxPatchManifest(_resourceVersion);
|
||||||
_steps = ESteps.InitPrepareCache;
|
_steps = ESteps.InitVerifyingCache;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -127,7 +127,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadWebManifest)
|
if (_steps == ESteps.LoadWebManifest)
|
||||||
{
|
{
|
||||||
string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestFileName(_updateResourceVersion));
|
string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestFileName(_resourceVersion));
|
||||||
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
||||||
_downloaderManifest = new UnityWebDataRequester();
|
_downloaderManifest = new UnityWebDataRequester();
|
||||||
_downloaderManifest.SendRequest(webURL, _timeout);
|
_downloaderManifest.SendRequest(webURL, _timeout);
|
||||||
|
@ -149,9 +149,9 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 解析补丁清单
|
// 解析补丁清单
|
||||||
if (ParseAndSaveRemotePatchManifest(_updateResourceVersion, _downloaderManifest.GetText()))
|
if (ParseAndSaveRemotePatchManifest(_resourceVersion, _downloaderManifest.GetText()))
|
||||||
{
|
{
|
||||||
_steps = ESteps.InitPrepareCache;
|
_steps = ESteps.InitVerifyingCache;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -163,16 +163,16 @@ namespace YooAsset
|
||||||
_downloaderManifest.Dispose();
|
_downloaderManifest.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitPrepareCache)
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
{
|
{
|
||||||
InitPrepareCache();
|
InitVerifyingCache();
|
||||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
_steps = ESteps.UpdatePrepareCache;
|
_steps = ESteps.UpdateVerifyingCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.UpdatePrepareCache)
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
{
|
{
|
||||||
if (UpdatePrepareCache())
|
if (UpdateVerifyingCache())
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
@ -182,6 +182,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取补丁清单请求地址
|
||||||
|
/// </summary>
|
||||||
private string GetPatchManifestRequestURL(string fileName)
|
private string GetPatchManifestRequestURL(string fileName)
|
||||||
{
|
{
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
|
@ -256,7 +259,7 @@ namespace YooAsset
|
||||||
private int _verifySuccessCount = 0;
|
private int _verifySuccessCount = 0;
|
||||||
private int _verifyFailCount = 0;
|
private int _verifyFailCount = 0;
|
||||||
|
|
||||||
private void InitPrepareCache()
|
private void InitVerifyingCache()
|
||||||
{
|
{
|
||||||
// 遍历所有文件然后验证并缓存合法文件
|
// 遍历所有文件然后验证并缓存合法文件
|
||||||
foreach (var patchBundle in _impl.LocalPatchManifest.BundleList)
|
foreach (var patchBundle in _impl.LocalPatchManifest.BundleList)
|
||||||
|
@ -286,7 +289,7 @@ namespace YooAsset
|
||||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||||
}
|
}
|
||||||
private bool UpdatePrepareCache()
|
private bool UpdateVerifyingCache()
|
||||||
{
|
{
|
||||||
_syncContext.Update();
|
_syncContext.Update();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,231 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public abstract class UpdatePackageOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 开始下载
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||||
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
|
public abstract PackageDownloaderOperation BeginDownloadPackage(int downloadingMaxNumber, int failedTryAgain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下模拟运行的更新资源包裹操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class EditorPlayModeUpdatePackageOperation : UpdatePackageOperation
|
||||||
|
{
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始下载
|
||||||
|
/// </summary>
|
||||||
|
public override PackageDownloaderOperation BeginDownloadPackage(int downloadingMaxNumber, int failedTryAgain)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
|
operation.BeginDownload();
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 离线模式的更新资源包裹操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class OfflinePlayModeUpdatePackageOperation : UpdatePackageOperation
|
||||||
|
{
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始下载
|
||||||
|
/// </summary>
|
||||||
|
public override PackageDownloaderOperation BeginDownloadPackage(int downloadingMaxNumber, int failedTryAgain)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
|
operation.BeginDownload();
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网络模式的更新资源包裹操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HostPlayModeUpdatePackageOperation : UpdatePackageOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadWebManifest,
|
||||||
|
CheckWebManifest,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int RequestCount = 0;
|
||||||
|
private readonly HostPlayModeImpl _impl;
|
||||||
|
private readonly int _resourceVersion;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private UnityWebDataRequester _downloaderManifest;
|
||||||
|
private PatchManifest _remotePatchManifest;
|
||||||
|
|
||||||
|
internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, int resourceVersion, int timeout)
|
||||||
|
{
|
||||||
|
_impl = impl;
|
||||||
|
_resourceVersion = resourceVersion;
|
||||||
|
_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 webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestFileName(_resourceVersion));
|
||||||
|
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
||||||
|
_downloaderManifest = new UnityWebDataRequester();
|
||||||
|
_downloaderManifest.SendRequest(webURL, _timeout);
|
||||||
|
_steps = ESteps.CheckWebManifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckWebManifest)
|
||||||
|
{
|
||||||
|
if (_downloaderManifest.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check error
|
||||||
|
if (_downloaderManifest.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _downloaderManifest.GetError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 解析补丁清单
|
||||||
|
if (ParseRemotePatchManifest(_downloaderManifest.GetText()))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"URL : {_downloaderManifest.URL} Error : remote patch manifest content is invalid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downloaderManifest.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始下载
|
||||||
|
/// </summary>
|
||||||
|
public override PackageDownloaderOperation BeginDownloadPackage(int downloadingMaxNumber, int failedTryAgain)
|
||||||
|
{
|
||||||
|
if (Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = GetDownloadList();
|
||||||
|
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
|
operation.BeginDownload();
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Error($"{nameof(UpdatePackageOperation)} status is failed !");
|
||||||
|
var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain);
|
||||||
|
operation.BeginDownload();
|
||||||
|
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 bool ParseRemotePatchManifest(string content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_remotePatchManifest = PatchManifest.Deserialize(content);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Warning(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取下载列表
|
||||||
|
/// </summary>
|
||||||
|
private List<BundleInfo> GetDownloadList()
|
||||||
|
{
|
||||||
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
|
foreach (var patchBundle in _remotePatchManifest.BundleList)
|
||||||
|
{
|
||||||
|
// 忽略缓存文件
|
||||||
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 忽略APP资源
|
||||||
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
|
if (_impl.AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
|
{
|
||||||
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:下载系统只会验证当前游戏版本的资源文件,对于其它游戏版本的差异文件不会在初始化的时候去做校验。
|
||||||
|
// 注意:通过比对文件大小做实时的文件校验方式!
|
||||||
|
string filePath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
long fileSize = FileUtility.GetFileSize(filePath);
|
||||||
|
if (fileSize == patchBundle.SizeBytes)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadList.Add(patchBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _impl.ConvertToDownloadList(downloadList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c4b754a3b15abc44fa2727f57721e18b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -42,9 +42,19 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步更新补丁清单
|
/// 异步更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UpdateManifestOperation UpdatePatchManifestAsync(int updateResourceVersion, int timeout)
|
public UpdateManifestOperation UpdatePatchManifestAsync(int resourceVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdateManifestOperation(this, updateResourceVersion, timeout);
|
var operation = new HostPlayModeUpdateManifestOperation(this, resourceVersion, timeout);
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步更新资源包裹
|
||||||
|
/// </summary>
|
||||||
|
public UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new HostPlayModeUpdatePackageOperation(this, resourceVersion, timeout);
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -62,10 +72,10 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建下载器
|
/// 创建下载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateDownloaderByAll(int fileLoadingMaxNumber, int failedTryAgain)
|
public PatchDownloaderOperation CreatePatchDownloaderByAll(int fileLoadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = GetDownloadListByAll();
|
List<BundleInfo> downloadList = GetDownloadListByAll();
|
||||||
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetDownloadListByAll()
|
private List<BundleInfo> GetDownloadListByAll()
|
||||||
|
@ -94,10 +104,10 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建下载器
|
/// 创建下载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain)
|
public PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
||||||
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
||||||
|
@ -140,10 +150,10 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建下载器
|
/// 创建下载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateDownloaderByPaths(List<string> assetPaths, int fileLoadingMaxNumber, int failedTryAgain)
|
public PatchDownloaderOperation CreatePatchDownloaderByPaths(List<string> assetPaths, int fileLoadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = GetDownloadListByPaths(assetPaths);
|
List<BundleInfo> downloadList = GetDownloadListByPaths(assetPaths);
|
||||||
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetDownloadListByPaths(List<string> assetPaths)
|
private List<BundleInfo> GetDownloadListByPaths(List<string> assetPaths)
|
||||||
|
@ -197,10 +207,10 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建解压器
|
/// 创建解压器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
||||||
var operation = new DownloaderOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +225,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
private List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
public List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
||||||
{
|
{
|
||||||
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
||||||
foreach (var patchBundle in downloadList)
|
foreach (var patchBundle in downloadList)
|
||||||
|
@ -225,7 +235,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
public BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
// 注意:资源版本号只用于确定下载路径
|
// 注意:资源版本号只用于确定下载路径
|
||||||
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
|
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
|
||||||
|
|
|
@ -31,10 +31,10 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建解压器
|
/// 创建解压器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
||||||
var operation = new DownloaderOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求静态资源版本号
|
/// 向网络端请求静态资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||||
|
@ -248,9 +248,9 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新补丁清单
|
/// 向网络端请求并更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="updateResourceVersion">更新的资源版本号</param>
|
/// <param name="resourceVersion">更新的资源版本</param>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public static UpdateManifestOperation UpdateManifestAsync(int updateResourceVersion, int timeout = 60)
|
public static UpdateManifestOperation UpdateManifestAsync(int resourceVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
|
@ -268,7 +268,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_hostPlayModeImpl == null)
|
if (_hostPlayModeImpl == null)
|
||||||
throw new Exception("YooAsset is not initialized.");
|
throw new Exception("YooAsset is not initialized.");
|
||||||
return _hostPlayModeImpl.UpdatePatchManifestAsync(updateResourceVersion, timeout);
|
return _hostPlayModeImpl.UpdatePatchManifestAsync(resourceVersion, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -343,7 +343,7 @@ namespace YooAsset
|
||||||
AssetSystem.GetDebugReport(report);
|
AssetSystem.GetDebugReport(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 场景加载接口
|
#region 场景加载
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载场景
|
/// 异步加载场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -359,7 +359,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 资源加载接口
|
#region 资源加载
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步获取原生文件
|
/// 异步获取原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -498,37 +498,37 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 资源下载接口
|
#region 资源下载
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁下载器,用于更新下载资源标签指定的文件
|
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tag">资源标签</param>
|
/// <param name="tag">资源标签</param>
|
||||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static DownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁下载器,用于更新下载资源标签指定的文件
|
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tags">资源标签列表</param>
|
/// <param name="tags">资源标签列表</param>
|
||||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static DownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
if (_hostPlayModeImpl == null)
|
if (_hostPlayModeImpl == null)
|
||||||
throw new Exception("YooAsset is not initialized.");
|
throw new Exception("YooAsset is not initialized.");
|
||||||
return _hostPlayModeImpl.CreateDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
|
return _hostPlayModeImpl.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -537,23 +537,23 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁下载器,用于更新下载所有文件
|
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static DownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
if (_hostPlayModeImpl == null)
|
if (_hostPlayModeImpl == null)
|
||||||
throw new Exception("YooAsset is not initialized.");
|
throw new Exception("YooAsset is not initialized.");
|
||||||
return _hostPlayModeImpl.CreateDownloaderByAll(downloadingMaxNumber, failedTryAgain);
|
return _hostPlayModeImpl.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -562,17 +562,17 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建资源包下载器,用于更新下载指定的资源列表
|
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="locations">资源列表</param>
|
/// <param name="locations">资源列表</param>
|
||||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static DownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
|
@ -586,7 +586,7 @@ namespace YooAsset
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||||
assetPaths.Add(assetPath);
|
assetPaths.Add(assetPath);
|
||||||
}
|
}
|
||||||
return _hostPlayModeImpl.CreateDownloaderByPaths(assetPaths, downloadingMaxNumber, failedTryAgain);
|
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetPaths, downloadingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -595,14 +595,14 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 资源解压接口
|
#region 资源解压
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁解压器
|
/// 创建补丁解压器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tag">资源标签</param>
|
/// <param name="tag">资源标签</param>
|
||||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||||
public static DownloaderOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
public static PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
return CreatePatchUnpacker(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
return CreatePatchUnpacker(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
|
@ -613,25 +613,58 @@ namespace YooAsset
|
||||||
/// <param name="tags">资源标签列表</param>
|
/// <param name="tags">资源标签列表</param>
|
||||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||||
public static DownloaderOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
public static PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
if (_offlinePlayModeImpl == null)
|
if (_offlinePlayModeImpl == null)
|
||||||
throw new Exception("YooAsset is not initialized.");
|
throw new Exception("YooAsset is not initialized.");
|
||||||
return _offlinePlayModeImpl.CreateUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
return _offlinePlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
if (_hostPlayModeImpl == null)
|
if (_hostPlayModeImpl == null)
|
||||||
throw new Exception("YooAsset is not initialized.");
|
throw new Exception("YooAsset is not initialized.");
|
||||||
return _hostPlayModeImpl.CreateUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
return _hostPlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 包裹更新
|
||||||
|
/// <summary>
|
||||||
|
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="resourceVersion">指定更新的资源版本</param>
|
||||||
|
/// <param name="timeout">超时时间</param>
|
||||||
|
public static UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout = 60)
|
||||||
|
{
|
||||||
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
|
{
|
||||||
|
var operation = new EditorPlayModeUpdatePackageOperation();
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
|
{
|
||||||
|
var operation = new OfflinePlayModeUpdatePackageOperation();
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
|
{
|
||||||
|
if (_hostPlayModeImpl == null)
|
||||||
|
throw new Exception("YooAsset is not initialized.");
|
||||||
|
return _hostPlayModeImpl.UpdatePackageAsync(resourceVersion, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue