mirror of https://github.com/tuyoogame/YooAsset
update runtime code
parent
5c16171781
commit
4e759134bd
|
@ -211,29 +211,29 @@ namespace YooAsset
|
|||
/// <param name="packageVersion">更新的包裹版本</param>
|
||||
/// <param name="autoActiveManifest">自动激活清单</param>
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest = true, bool autoActiveManifest = true, int timeout = 60)
|
||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile = true, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
DebugCheckUpdateManifest();
|
||||
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveManifest, autoActiveManifest, timeout);
|
||||
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveManifestFile, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查本地包裹内容的完整性
|
||||
/// 检查包裹内容的完整性
|
||||
/// </summary>
|
||||
public CheckPackageContentsOperation CheckPackageContentsAsync()
|
||||
public CheckContentsIntegrityOperation CheckContentsIntegrityAsync()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.CheckPackageContentsAsync();
|
||||
return _playModeServices.CheckContentsIntegrityAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理本地包裹未使用的缓存文件
|
||||
/// 清理包裹未使用的缓存文件
|
||||
/// </summary>
|
||||
public ClearPackageUnusedCacheFilesOperation ClearPackageUnusedCacheFilesAsync()
|
||||
public ClearUnusedCacheFilesOperation ClearUnusedCacheFilesAsync()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var operation = new ClearPackageUnusedCacheFilesOperation(this);
|
||||
var operation = new ClearUnusedCacheFilesOperation(this);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查包裹内容的完整性
|
||||
/// </summary>
|
||||
public abstract class CheckContentsIntegrityOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
|
||||
internal sealed class EditorSimulateModeCheckContentsIntegrityOperation : CheckContentsIntegrityOperation
|
||||
{
|
||||
internal EditorSimulateModeCheckContentsIntegrityOperation()
|
||||
{
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
internal sealed class OfflinePlayModeCheckContentsIntegrityOperation : CheckContentsIntegrityOperation
|
||||
{
|
||||
internal OfflinePlayModeCheckContentsIntegrityOperation()
|
||||
{
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
internal sealed class HostPlayModeCheckContentsIntegrityOperation : CheckContentsIntegrityOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckLoadedManifest,
|
||||
StartVerifyOperation,
|
||||
CheckVerifyOperation,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeCheckContentsIntegrityOperation(HostPlayModeImpl impl, string packageName)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageName = packageName;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.CheckLoadedManifest;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckLoadedManifest)
|
||||
{
|
||||
if (_impl.ActivePatchManifest == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Not found loaded package : {_packageName}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
{
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_impl.ActivePatchManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckVerifyOperation)
|
||||
{
|
||||
Progress = _verifyOperation.Progress;
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
||||
bool verifySucceed = true;
|
||||
foreach (var verifyInfo in _verifyOperation.VerifyFailList)
|
||||
{
|
||||
// 注意:跳过内置资源文件
|
||||
if (verifyInfo.IsBuildinFile)
|
||||
continue;
|
||||
|
||||
verifySucceed = false;
|
||||
YooLogger.Warning($"Failed verify file : {verifyInfo.VerifyFilePath}");
|
||||
}
|
||||
|
||||
if (verifySucceed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The package resource {_packageName} content has verify failed file !";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查本地包裹内容的完整性
|
||||
/// </summary>
|
||||
public abstract class CheckPackageContentsOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
|
||||
internal sealed class EditorSimulateModeCheckPackageContentsOperation : CheckPackageContentsOperation
|
||||
{
|
||||
internal EditorSimulateModeCheckPackageContentsOperation()
|
||||
{
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
internal sealed class OfflinePlayModeCheckPackageContentsOperation : CheckPackageContentsOperation
|
||||
{
|
||||
internal OfflinePlayModeCheckPackageContentsOperation()
|
||||
{
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
internal sealed class HostPlayModeCheckPackageContentsOperation : CheckPackageContentsOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckLoadedManifest,
|
||||
StartVerifyOperation,
|
||||
CheckVerifyOperation,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private CacheFilesVerifyOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private float _verifyTime;
|
||||
|
||||
internal HostPlayModeCheckPackageContentsOperation(HostPlayModeImpl impl, string packageName)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageName = packageName;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.CheckLoadedManifest;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckLoadedManifest)
|
||||
{
|
||||
if (_impl.ActivePatchManifest == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Not found loaded package : {_packageName}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||
#else
|
||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||
#endif
|
||||
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckVerifyOperation)
|
||||
{
|
||||
Progress = _verifyOperation.Progress;
|
||||
if (_verifyOperation.IsDone)
|
||||
{
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_verifyOperation.VerifySuccessList.Count}, Fail {_verifyOperation.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
|
||||
bool verifySucceed = true;
|
||||
foreach (var verifyInfo in _verifyOperation.VerifyFailList)
|
||||
{
|
||||
// 注意:跳过内置资源文件
|
||||
if (verifyInfo.IsBuildinFile)
|
||||
continue;
|
||||
|
||||
verifySucceed = false;
|
||||
YooLogger.Warning($"Failed verify file : {verifyInfo.VerifyFilePath}");
|
||||
}
|
||||
|
||||
if (verifySucceed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The package resource {_packageName} content has verify failed file !";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 清理本地包裹未使用的缓存文件
|
||||
/// </summary>
|
||||
public sealed class ClearPackageUnusedCacheFilesOperation : AsyncOperationBase
|
||||
public sealed class ClearUnusedCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -18,11 +18,11 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
private readonly AssetsPackage _package;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private List<string> _unusedCacheFilePaths;
|
||||
private int _unusedFileTotalCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal ClearPackageUnusedCacheFilesOperation(AssetsPackage package)
|
||||
internal ClearUnusedCacheFilesOperation(AssetsPackage package)
|
||||
{
|
||||
_package = package;
|
||||
}
|
|
@ -29,10 +29,10 @@ namespace YooAsset
|
|||
private readonly List<DownloaderBase> _failedList = new List<DownloaderBase>(MAX_LOADER_COUNT);
|
||||
|
||||
// 数据相关
|
||||
private ESteps _steps = ESteps.None;
|
||||
private bool _isPause = false;
|
||||
private long _lastDownloadBytes = 0;
|
||||
private int _lastDownloadCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -101,17 +101,15 @@ namespace YooAsset
|
|||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private BuildinPackageVersionQueryOperation _buildinPackageVersionQuery;
|
||||
private BuildinManifestLoadOperation _buildinManifestLoad;
|
||||
private CacheFilesVerifyOperation _verifyOperation;
|
||||
private QueryBuildinPackageVersionOperation _buildinPackageVersionQuery;
|
||||
private LoadBuildinManifestOperation _buildinManifestLoad;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private float _verifyTime;
|
||||
|
||||
|
||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, string packageName)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageName = packageName;
|
||||
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
|
@ -126,7 +124,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_buildinPackageVersionQuery == null)
|
||||
{
|
||||
_buildinPackageVersionQuery = new BuildinPackageVersionQueryOperation(_packageName);
|
||||
_buildinPackageVersionQuery = new QueryBuildinPackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_buildinPackageVersionQuery);
|
||||
}
|
||||
|
||||
|
@ -149,7 +147,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_buildinManifestLoad == null)
|
||||
{
|
||||
_buildinManifestLoad = new BuildinManifestLoadOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
_buildinManifestLoad = new LoadBuildinManifestOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
OperationSystem.StartOperation(_buildinManifestLoad);
|
||||
}
|
||||
|
||||
|
@ -173,14 +171,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||
#else
|
||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||
#endif
|
||||
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_impl.ActivePatchManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
|
@ -191,8 +183,6 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_verifyOperation.VerifySuccessList.Count}, Fail {_verifyOperation.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,13 +209,12 @@ namespace YooAsset
|
|||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private BuildinPackageVersionQueryOperation _buildinPackageVersionQuery;
|
||||
private BuildinManifestCopyOperation _buildinManifestCopy;
|
||||
private BuildinManifestLoadOperation _buildinManifestLoad;
|
||||
private CacheManifestLoadOperation _cacheManifestLoad;
|
||||
private CacheFilesVerifyOperation _verifyOperation;
|
||||
private QueryBuildinPackageVersionOperation _buildinPackageVersionQuery;
|
||||
private CopyBuildinManifestOperation _buildinManifestCopy;
|
||||
private LoadBuildinManifestOperation _buildinManifestLoad;
|
||||
private LoadCacheManifestOperation _cacheManifestLoad;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private float _verifyTime;
|
||||
|
||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl, string packageName)
|
||||
{
|
||||
|
@ -260,7 +249,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_cacheManifestLoad == null)
|
||||
{
|
||||
_cacheManifestLoad = new CacheManifestLoadOperation(_packageName);
|
||||
_cacheManifestLoad = new LoadCacheManifestOperation(_packageName);
|
||||
OperationSystem.StartOperation(_cacheManifestLoad);
|
||||
}
|
||||
|
||||
|
@ -283,7 +272,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_buildinPackageVersionQuery == null)
|
||||
{
|
||||
_buildinPackageVersionQuery = new BuildinPackageVersionQueryOperation(_packageName);
|
||||
_buildinPackageVersionQuery = new QueryBuildinPackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_buildinPackageVersionQuery);
|
||||
}
|
||||
|
||||
|
@ -308,7 +297,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_buildinManifestCopy == null)
|
||||
{
|
||||
_buildinManifestCopy = new BuildinManifestCopyOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
_buildinManifestCopy = new CopyBuildinManifestOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
OperationSystem.StartOperation(_buildinManifestCopy);
|
||||
}
|
||||
|
||||
|
@ -332,7 +321,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_buildinManifestLoad == null)
|
||||
{
|
||||
_buildinManifestLoad = new BuildinManifestLoadOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
_buildinManifestLoad = new LoadBuildinManifestOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
OperationSystem.StartOperation(_buildinManifestLoad);
|
||||
}
|
||||
|
||||
|
@ -356,14 +345,8 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||
#else
|
||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||
#endif
|
||||
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_impl.ActivePatchManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
|
@ -374,8 +357,6 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_verifyOperation.VerifySuccessList.Count}, Fail {_verifyOperation.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ba3f4fc8cf6941f4a96ab928cec547e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -4,7 +4,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 内置补丁清单复制器
|
||||
/// </summary>
|
||||
internal class BuildinManifestCopyOperation : AsyncOperationBase
|
||||
internal class CopyBuildinManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace YooAsset
|
|||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public BuildinManifestCopyOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
public CopyBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
{
|
||||
_buildinPackageName = buildinPackageName;
|
||||
_buildinPackageVersion = buildinPackageVersion;
|
|
@ -19,15 +19,13 @@ namespace YooAsset
|
|||
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
private readonly BufferReader _buffer;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private int _patchAssetCount;
|
||||
private int _patchBundleCount;
|
||||
private int _progressTotalValue;
|
||||
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public DeserializeManifestOperation(byte[] binaryData)
|
||||
{
|
||||
// 创建缓存器
|
||||
_buffer = new BufferReader(binaryData);
|
||||
}
|
||||
internal override void Start()
|
||||
|
@ -43,13 +41,21 @@ namespace YooAsset
|
|||
{
|
||||
if (_steps == ESteps.DeserializeFileHeader)
|
||||
{
|
||||
if (_buffer.IsValid == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Buffer is invalid !";
|
||||
return;
|
||||
}
|
||||
|
||||
// 读取文件标记
|
||||
uint fileSign = _buffer.ReadUInt32();
|
||||
if (fileSign != YooAssetSettings.PatchManifestFileSign)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Invalid manifest file format !";
|
||||
Error = "The manifest file format is invalid !";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,7 +157,7 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
}
|
||||
catch(System.Exception e)
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Manifest = null;
|
||||
_steps = ESteps.Done;
|
|
@ -4,7 +4,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 内置补丁清单加载器
|
||||
/// </summary>
|
||||
internal class BuildinManifestLoadOperation : AsyncOperationBase
|
||||
internal class LoadBuildinManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ namespace YooAsset
|
|||
public PatchManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public BuildinManifestLoadOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
public LoadBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
{
|
||||
_buildinPackageName = buildinPackageName;
|
||||
_buildinPackageVersion = buildinPackageVersion;
|
|
@ -5,7 +5,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 沙盒补丁清单加载器
|
||||
/// </summary>
|
||||
internal class CacheManifestLoadOperation : AsyncOperationBase
|
||||
internal class LoadCacheManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -17,8 +17,8 @@ namespace YooAsset
|
|||
|
||||
private readonly string _packageName;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private string _manifestFilePath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 加载结果
|
||||
|
@ -26,7 +26,7 @@ namespace YooAsset
|
|||
public PatchManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public CacheManifestLoadOperation(string packageName)
|
||||
public LoadCacheManifestOperation(string packageName)
|
||||
{
|
||||
_packageName = packageName;
|
||||
}
|
|
@ -4,7 +4,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 内置补丁清单版本查询器
|
||||
/// </summary>
|
||||
internal class BuildinPackageVersionQueryOperation : AsyncOperationBase
|
||||
internal class QueryBuildinPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace YooAsset
|
|||
public string Version { private set; get; }
|
||||
|
||||
|
||||
public BuildinPackageVersionQueryOperation(string packageName)
|
||||
public QueryBuildinPackageVersionOperation(string packageName)
|
||||
{
|
||||
_packageName = packageName;
|
||||
}
|
|
@ -9,16 +9,26 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 本地缓存文件验证
|
||||
/// </summary>
|
||||
internal abstract class CacheFilesVerifyOperation : AsyncOperationBase
|
||||
internal abstract class VerifyCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
public List<VerifyInfo> VerifySuccessList { protected set; get; }
|
||||
public List<VerifyInfo> VerifyFailList { protected set; get; }
|
||||
}
|
||||
|
||||
public static VerifyCacheFilesOperation CreateOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
VerifyCacheFilesOperation operation = new VerifyCacheFilesWithoutThreadOperation(patchManifest, playModeServices);
|
||||
#else
|
||||
VerifyCacheFilesOperation operation = new VerifyCacheFilesWithThreadOperation(patchManifest, playModeServices);
|
||||
#endif
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证(线程版)
|
||||
/// </summary>
|
||||
internal class CacheFilesVerifyWithThreadOperation : CacheFilesVerifyOperation
|
||||
internal class VerifyCacheFilesWithThreadOperation : VerifyCacheFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -31,15 +41,15 @@ namespace YooAsset
|
|||
|
||||
private readonly PatchManifest _patchManifest;
|
||||
private readonly IPlayModeServices _playModeServices;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private List<VerifyInfo> _waitingList;
|
||||
private List<VerifyInfo> _verifyingList;
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
private float _verifyStartTime;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public CacheFilesVerifyWithThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
public VerifyCacheFilesWithThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
{
|
||||
_patchManifest = patchManifest;
|
||||
_playModeServices = playModeServices;
|
||||
|
@ -47,6 +57,7 @@ namespace YooAsset
|
|||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.InitVerify;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
|
@ -95,6 +106,8 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyStartTime;
|
||||
YooLogger.Log($"Verify elapsed time {costTime:f1} seconds");
|
||||
}
|
||||
|
||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
||||
|
@ -162,7 +175,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 本地缓存文件验证(非线程版)
|
||||
/// </summary>
|
||||
internal class CacheFilesVerifyWithoutThreadOperation : CacheFilesVerifyOperation
|
||||
internal class VerifyCacheFilesWithoutThreadOperation : VerifyCacheFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -175,14 +188,14 @@ namespace YooAsset
|
|||
|
||||
private readonly PatchManifest _patchManifest;
|
||||
private readonly IPlayModeServices _playModeServices;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
private List<VerifyInfo> _waitingList;
|
||||
private List<VerifyInfo> _verifyingList;
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
private float _verifyStartTime;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public CacheFilesVerifyWithoutThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
public VerifyCacheFilesWithoutThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
{
|
||||
_patchManifest = patchManifest;
|
||||
_playModeServices = playModeServices;
|
||||
|
@ -190,6 +203,7 @@ namespace YooAsset
|
|||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.InitVerify;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
|
@ -232,6 +246,8 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyStartTime;
|
||||
YooLogger.Log($"Verify elapsed time {costTime:f1} seconds");
|
||||
}
|
||||
|
||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
|
@ -10,131 +10,20 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
internal IPlayModeServices _playModeServices;
|
||||
internal PatchManifest _patchManifest;
|
||||
|
||||
/// <summary>
|
||||
/// 是否发现了新的补丁清单
|
||||
/// 发现了新的清单
|
||||
/// </summary>
|
||||
public bool FoundNewManifest { protected set; get; } = false;
|
||||
|
||||
#region 资源下载
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
|
||||
/// 手动保存清单文件
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
return _playModeServices.CreatePatchDownloaderByTags(_patchManifest, new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public virtual void SaveManifestFile() { }
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
|
||||
/// 还原补丁清单
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
return _playModeServices.CreatePatchDownloaderByTags(_patchManifest, tags, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
return _playModeServices.CreatePatchDownloaderByAll(_patchManifest, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfos">资源信息列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call downloader !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
return _playModeServices.CreatePatchDownloaderByPaths(_patchManifest, assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源解压
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call unpacker !");
|
||||
return PatchUnpackerOperation.CreateEmptyUnpacker(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
return _playModeServices.CreatePatchUnpackerByTags(_patchManifest, new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call unpacker !");
|
||||
return PatchUnpackerOperation.CreateEmptyUnpacker(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
return _playModeServices.CreatePatchUnpackerByTags(_patchManifest, tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// </summary>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Please check { nameof(UpdatePackageManifestOperation)} status before call unpacker !");
|
||||
return PatchUnpackerOperation.CreateEmptyUnpacker(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
return _playModeServices.CreatePatchUnpackerByAll(_patchManifest, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
#endregion
|
||||
public virtual void RevertManifest() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -142,9 +31,8 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal sealed class EditorPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
{
|
||||
public EditorPlayModeUpdatePackageManifestOperation(EditorSimulateModeImpl impl)
|
||||
public EditorPlayModeUpdatePackageManifestOperation()
|
||||
{
|
||||
_playModeServices = impl;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
|
@ -160,9 +48,8 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
{
|
||||
public OfflinePlayModeUpdatePackageManifestOperation(OfflinePlayModeImpl impl)
|
||||
public OfflinePlayModeUpdatePackageManifestOperation()
|
||||
{
|
||||
_playModeServices = impl;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
|
@ -197,27 +84,24 @@ namespace YooAsset
|
|||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageVersion;
|
||||
private bool _autoSaveManifest;
|
||||
private bool _autoActiveManifest;
|
||||
private readonly bool _autoSaveManifestFile;
|
||||
private readonly int _timeout;
|
||||
private UnityWebDataRequester _downloader1;
|
||||
private UnityWebDataRequester _downloader2;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private CacheFilesVerifyOperation _verifyOperation;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
|
||||
internal PatchManifest _prePatchManifest;
|
||||
private string _cacheManifestHash;
|
||||
private byte[] _fileBytesData = null;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private byte[] _fileBytes = null;
|
||||
private float _verifyTime;
|
||||
|
||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
{
|
||||
_playModeServices = impl;
|
||||
_impl = impl;
|
||||
_packageName = packageName;
|
||||
_packageVersion = packageVersion;
|
||||
_autoSaveManifest = autoSaveManifest;
|
||||
_autoActiveManifest = autoActiveManifest;
|
||||
_autoSaveManifestFile = autoSaveManifestFile;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void Start()
|
||||
|
@ -234,7 +118,7 @@ namespace YooAsset
|
|||
{
|
||||
string filePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
{
|
||||
_cacheManifestHash = HashUtility.FileMD5(filePath);
|
||||
_steps = ESteps.DownloadWebHash;
|
||||
}
|
||||
|
@ -271,7 +155,6 @@ namespace YooAsset
|
|||
if (_cacheManifestHash == webManifestHash)
|
||||
{
|
||||
YooLogger.Log($"Not found new package : {_packageName}");
|
||||
_patchManifest = _impl.ActivePatchManifest;
|
||||
FoundNewManifest = false;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
|
@ -310,16 +193,13 @@ namespace YooAsset
|
|||
else
|
||||
{
|
||||
byte[] bytesData = _downloader2.GetData();
|
||||
|
||||
// 保存文件到沙盒内
|
||||
if (_autoSaveManifest)
|
||||
if (_autoSaveManifestFile)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
FileUtility.CreateFile(savePath, bytesData);
|
||||
SaveManifestFileInternal(bytesData);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fileBytes = bytesData;
|
||||
_fileBytesData = bytesData;
|
||||
}
|
||||
|
||||
// 解析二进制数据
|
||||
|
@ -334,37 +214,27 @@ namespace YooAsset
|
|||
if (_steps == ESteps.CheckDeserializeWebManifest)
|
||||
{
|
||||
Progress = _deserializer.Progress;
|
||||
if (_deserializer.IsDone)
|
||||
{
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_autoActiveManifest)
|
||||
{
|
||||
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||
}
|
||||
if (_deserializer.IsDone == false)
|
||||
return;
|
||||
|
||||
_patchManifest = _deserializer.Manifest;
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
}
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_prePatchManifest = _impl.ActivePatchManifest;
|
||||
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_deserializer.Manifest, _impl);
|
||||
#else
|
||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_deserializer.Manifest, _impl);
|
||||
#endif
|
||||
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_deserializer.Manifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
|
@ -375,8 +245,6 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_verifyOperation.VerifySuccessList.Count}, Fail {_verifyOperation.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -384,37 +252,50 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 手动保存清单文件
|
||||
/// </summary>
|
||||
public void SaveManifest()
|
||||
public override void SaveManifestFile()
|
||||
{
|
||||
if (_autoSaveManifest == false)
|
||||
if (IsDone == false)
|
||||
{
|
||||
if (_fileBytes != null)
|
||||
YooLogger.Warning($"{nameof(UpdatePackageManifestOperation)} is not done !");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_fileBytesData != null)
|
||||
{
|
||||
_autoSaveManifest = true;
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
FileUtility.CreateFile(savePath, _fileBytes);
|
||||
SaveManifestFileInternal(_fileBytesData);
|
||||
_fileBytesData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动激活清单文件
|
||||
/// 还原补丁清单
|
||||
/// </summary>
|
||||
public void ActiveManifest()
|
||||
public override void RevertManifest()
|
||||
{
|
||||
if (_autoActiveManifest == false)
|
||||
if (IsDone == false)
|
||||
{
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
YooLogger.Warning($"{nameof(UpdatePackageManifestOperation)} is not done !");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_prePatchManifest != null)
|
||||
{
|
||||
_autoActiveManifest = true;
|
||||
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||
_impl.ActivePatchManifest = _prePatchManifest;
|
||||
_prePatchManifest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁清单请求地址
|
||||
/// </summary>
|
||||
private void SaveManifestFileInternal(byte[] bytesData)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
FileUtility.CreateFile(savePath, bytesData);
|
||||
}
|
||||
private string GetPatchManifestRequestURL(string fileName)
|
||||
{
|
||||
// 轮流返回请求地址
|
||||
|
|
|
@ -51,8 +51,8 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadStaticVersion,
|
||||
CheckStaticVersion,
|
||||
LoadPackageVersion,
|
||||
CheckLoadPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
|
@ -74,24 +74,24 @@ namespace YooAsset
|
|||
internal override void Start()
|
||||
{
|
||||
RequestCount++;
|
||||
_steps = ESteps.LoadStaticVersion;
|
||||
_steps = ESteps.LoadPackageVersion;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadStaticVersion)
|
||||
if (_steps == ESteps.LoadPackageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
|
||||
string webURL = GetStaticVersionRequestURL(fileName);
|
||||
string webURL = GetPackageVersionRequestURL(fileName);
|
||||
YooLogger.Log($"Beginning to request package version : {webURL}");
|
||||
_downloader = new UnityWebDataRequester();
|
||||
_downloader.SendRequest(webURL, _timeout);
|
||||
_steps = ESteps.CheckStaticVersion;
|
||||
_steps = ESteps.CheckLoadPackageVersion;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckStaticVersion)
|
||||
if (_steps == ESteps.CheckLoadPackageVersion)
|
||||
{
|
||||
Progress = _downloader.Progress();
|
||||
if (_downloader.IsDone() == false)
|
||||
|
@ -123,7 +123,7 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
private string GetStaticVersionRequestURL(string fileName)
|
||||
private string GetPackageVersionRequestURL(string fileName)
|
||||
{
|
||||
string url;
|
||||
|
||||
|
|
|
@ -52,59 +52,36 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdatePackageManifestOperation(this);
|
||||
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
CheckPackageContentsOperation IPlayModeServices.CheckPackageContentsAsync()
|
||||
CheckContentsIntegrityOperation IPlayModeServices.CheckContentsIntegrityAsync()
|
||||
{
|
||||
var operation = new EditorSimulateModeCheckPackageContentsOperation();
|
||||
var operation = new EditorSimulateModeCheckContentsIntegrityOperation();
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -109,25 +109,19 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, autoSaveManifest, autoActiveManifest, timeout);
|
||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, autoSaveManifestFile, timeout);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
CheckPackageContentsOperation IPlayModeServices.CheckPackageContentsAsync()
|
||||
CheckContentsIntegrityOperation IPlayModeServices.CheckContentsIntegrityAsync()
|
||||
{
|
||||
var operation = new HostPlayModeCheckPackageContentsOperation(this, _packageName);
|
||||
var operation = new HostPlayModeCheckContentsIntegrityOperation(this, _packageName);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll(patchManifest);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll(_activePatchManifest);
|
||||
|
@ -153,12 +147,6 @@ namespace YooAsset
|
|||
return ConvertToDownloadList(downloadList);
|
||||
}
|
||||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(PatchManifest patchManifest, string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(patchManifest, tags);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(_activePatchManifest, tags);
|
||||
|
@ -196,12 +184,6 @@ namespace YooAsset
|
|||
return ConvertToDownloadList(downloadList);
|
||||
}
|
||||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(patchManifest, assetInfos);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(_activePatchManifest, assetInfos);
|
||||
|
@ -251,12 +233,6 @@ namespace YooAsset
|
|||
return ConvertToDownloadList(downloadList);
|
||||
}
|
||||
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll(patchManifest);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll(_activePatchManifest);
|
||||
|
@ -281,12 +257,6 @@ namespace YooAsset
|
|||
return ConvertToUnpackList(downloadList);
|
||||
}
|
||||
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(PatchManifest patchManifest, string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(patchManifest, tags);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(_activePatchManifest, tags);
|
||||
|
|
|
@ -52,59 +52,36 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
{
|
||||
var operation = new OfflinePlayModeUpdatePackageManifestOperation(this);
|
||||
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
CheckPackageContentsOperation IPlayModeServices.CheckPackageContentsAsync()
|
||||
CheckContentsIntegrityOperation IPlayModeServices.CheckContentsIntegrityAsync()
|
||||
{
|
||||
var operation = new OfflinePlayModeCheckPackageContentsOperation();
|
||||
var operation = new OfflinePlayModeCheckContentsIntegrityOperation();
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(PatchManifest patchManifest, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(PatchManifest patchManifest, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -26,25 +26,20 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 向网络端请求并更新补丁清单
|
||||
/// </summary>
|
||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout);
|
||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// 检查本地包裹内容的完整性
|
||||
/// 检查包裹内容的完整性
|
||||
/// </summary>
|
||||
CheckPackageContentsOperation CheckPackageContentsAsync();
|
||||
CheckContentsIntegrityOperation CheckContentsIntegrityAsync();
|
||||
|
||||
// 下载相关方法
|
||||
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 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);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,20 @@ namespace YooAsset
|
|||
_buffer = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否有效
|
||||
/// </summary>
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_buffer == null || _buffer.Length == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓冲区容量
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue