mirror of https://github.com/tuyoogame/YooAsset
update runtime code
parent
a95697088b
commit
16943d4590
|
@ -211,11 +211,11 @@ namespace YooAsset
|
|||
/// <param name="packageVersion">更新的包裹版本</param>
|
||||
/// <param name="autoActiveManifest">自动激活清单</param>
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile = true, int timeout = 60)
|
||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
DebugCheckUpdateManifest();
|
||||
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveManifestFile, timeout);
|
||||
return _playModeServices.UpdatePackageManifestAsync(packageVersion, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -244,7 +244,9 @@ namespace YooAsset
|
|||
public string GetPackageVersion()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.GetPackageVersion();
|
||||
if (_playModeServices.ActiveManifest == null)
|
||||
return string.Empty;
|
||||
return _playModeServices.ActiveManifest.PackageVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal class UnityWebDataRequester
|
||||
{
|
||||
protected UnityWebRequest _webRequest;
|
||||
protected UnityWebRequestAsyncOperation _operationHandle;
|
||||
private UnityWebRequest _webRequest;
|
||||
private UnityWebRequestAsyncOperation _operationHandle;
|
||||
|
||||
/// <summary>
|
||||
/// 请求URL地址
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
|
@ -11,8 +12,14 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal class UnityWebFileRequester
|
||||
{
|
||||
protected UnityWebRequest _webRequest;
|
||||
protected UnityWebRequestAsyncOperation _operationHandle;
|
||||
private UnityWebRequest _webRequest;
|
||||
private UnityWebRequestAsyncOperation _operationHandle;
|
||||
|
||||
// 超时相关
|
||||
private float _timeout;
|
||||
private bool _isAbort = false;
|
||||
private ulong _latestDownloadBytes;
|
||||
private float _latestDownloadRealtime;
|
||||
|
||||
/// <summary>
|
||||
/// 请求URL地址
|
||||
|
@ -23,11 +30,12 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 发送GET请求
|
||||
/// </summary>
|
||||
public void SendRequest(string url, string savePath)
|
||||
public void SendRequest(string url, string savePath, float timeout = 60)
|
||||
{
|
||||
if (_webRequest == null)
|
||||
{
|
||||
URL = url;
|
||||
_timeout = timeout;
|
||||
_webRequest = new UnityWebRequest(URL, UnityWebRequest.kHttpVerbGET);
|
||||
DownloadHandlerFile handler = new DownloadHandlerFile(savePath);
|
||||
handler.removeFileOnAbort = true;
|
||||
|
@ -96,5 +104,28 @@ namespace YooAsset
|
|||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测超时
|
||||
/// </summary>
|
||||
public void CheckTimeout()
|
||||
{
|
||||
// 注意:在连续时间段内无新增下载数据及判定为超时
|
||||
if (_isAbort == false)
|
||||
{
|
||||
if (_latestDownloadBytes != _webRequest.downloadedBytes)
|
||||
{
|
||||
_latestDownloadBytes = _webRequest.downloadedBytes;
|
||||
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
float offset = Time.realtimeSinceStartup - _latestDownloadRealtime;
|
||||
if (offset > _timeout)
|
||||
{
|
||||
_webRequest.Abort();
|
||||
_isAbort = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,14 +44,13 @@ namespace YooAsset
|
|||
{
|
||||
None,
|
||||
CheckLoadedManifest,
|
||||
StartVerifyOperation,
|
||||
CheckVerifyOperation,
|
||||
VerifyPackage,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
private VerifyPackageOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeCheckContentsIntegrityOperation(HostPlayModeImpl impl, string packageName)
|
||||
|
@ -70,7 +69,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.CheckLoadedManifest)
|
||||
{
|
||||
if (_impl.ActivePatchManifest == null)
|
||||
if (_impl.ActiveManifest == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
|
@ -78,19 +77,18 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
_steps = ESteps.VerifyPackage;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
if (_steps == ESteps.VerifyPackage)
|
||||
{
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_impl.ActivePatchManifest, _impl);
|
||||
if (_verifyOperation == null)
|
||||
{
|
||||
_verifyOperation = VerifyPackageOperation.CreateOperation(_impl.ActiveManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckVerifyOperation)
|
||||
{
|
||||
Progress = _verifyOperation.Progress;
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
|
|
@ -10,10 +10,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public abstract class InitializationOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化内部加载的包裹版本
|
||||
/// </summary>
|
||||
public string InitializedPackageVersion;
|
||||
public string PackageVersion { protected set; get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -24,53 +21,41 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadManifestFileData,
|
||||
CheckDeserializeManifest,
|
||||
LoadEditorManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private readonly string _simulatePatchManifestPath;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private readonly string _simulateManifestPath;
|
||||
private LoadEditorManifestOperation _loadEditorManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulatePatchManifestPath)
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestPath)
|
||||
{
|
||||
_impl = impl;
|
||||
_simulatePatchManifestPath = simulatePatchManifestPath;
|
||||
_simulateManifestPath = simulateManifestPath;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.LoadManifestFileData;
|
||||
_steps = ESteps.LoadEditorManifest;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.LoadManifestFileData)
|
||||
if (_steps == ESteps.LoadEditorManifest)
|
||||
{
|
||||
if (File.Exists(_simulatePatchManifestPath) == false)
|
||||
if (_loadEditorManifestOp == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Not found simulation manifest file : {_simulatePatchManifestPath}";
|
||||
return;
|
||||
_loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestPath);
|
||||
OperationSystem.StartOperation(_loadEditorManifestOp);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Load simulation manifest file : {_simulatePatchManifestPath}");
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(_simulatePatchManifestPath);
|
||||
_deserializer = new DeserializeManifestOperation(bytesData);
|
||||
OperationSystem.StartOperation(_deserializer);
|
||||
_steps = ESteps.CheckDeserializeManifest;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckDeserializeManifest)
|
||||
{
|
||||
if (_deserializer.IsDone == false)
|
||||
if (_loadEditorManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
if (_loadEditorManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
InitializedPackageVersion = _deserializer.Manifest.PackageVersion;
|
||||
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||
PackageVersion = _loadEditorManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadEditorManifestOp.Manifest;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
@ -78,7 +63,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
Error = _loadEditorManifestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,16 +79,15 @@ namespace YooAsset
|
|||
None,
|
||||
QueryBuildinPackageVersion,
|
||||
LoadBuildinManifest,
|
||||
StartVerifyOperation,
|
||||
CheckVerifyOperation,
|
||||
VerifyPackage,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private QueryBuildinPackageVersionOperation _buildinPackageVersionQuery;
|
||||
private LoadBuildinManifestOperation _buildinManifestLoad;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
private QueryBuildinPackageVersionOperation _queryBuildinPackageVersionOp;
|
||||
private LoadBuildinManifestOperation _loadBuildinManifestOp;
|
||||
private VerifyPackageOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, string packageName)
|
||||
|
@ -122,16 +106,16 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.QueryBuildinPackageVersion)
|
||||
{
|
||||
if (_buildinPackageVersionQuery == null)
|
||||
if (_queryBuildinPackageVersionOp == null)
|
||||
{
|
||||
_buildinPackageVersionQuery = new QueryBuildinPackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_buildinPackageVersionQuery);
|
||||
_queryBuildinPackageVersionOp = new QueryBuildinPackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_queryBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_buildinPackageVersionQuery.IsDone == false)
|
||||
if (_queryBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_buildinPackageVersionQuery.Status == EOperationStatus.Succeed)
|
||||
if (_queryBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadBuildinManifest;
|
||||
}
|
||||
|
@ -139,45 +123,44 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _buildinPackageVersionQuery.Error;
|
||||
Error = _queryBuildinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuildinManifest)
|
||||
{
|
||||
if (_buildinManifestLoad == null)
|
||||
if (_loadBuildinManifestOp == null)
|
||||
{
|
||||
_buildinManifestLoad = new LoadBuildinManifestOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
OperationSystem.StartOperation(_buildinManifestLoad);
|
||||
_loadBuildinManifestOp = new LoadBuildinManifestOperation(_packageName, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_loadBuildinManifestOp);
|
||||
}
|
||||
|
||||
Progress = _buildinManifestLoad.Progress;
|
||||
if (_buildinManifestLoad.IsDone == false)
|
||||
Progress = _loadBuildinManifestOp.Progress;
|
||||
if (_loadBuildinManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_buildinManifestLoad.Status == EOperationStatus.Succeed)
|
||||
if (_loadBuildinManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
InitializedPackageVersion = _buildinManifestLoad.Manifest.PackageVersion;
|
||||
_impl.ActivePatchManifest = _buildinManifestLoad.Manifest;
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
PackageVersion = _loadBuildinManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadBuildinManifestOp.Manifest;
|
||||
_steps = ESteps.VerifyPackage;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _buildinManifestLoad.Error;
|
||||
Error = _loadBuildinManifestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
if (_steps == ESteps.VerifyPackage)
|
||||
{
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_impl.ActivePatchManifest, _impl);
|
||||
if (_verifyOperation == null)
|
||||
{
|
||||
_verifyOperation = VerifyPackageOperation.CreateOperation(_impl.ActiveManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckVerifyOperation)
|
||||
{
|
||||
Progress = _verifyOperation.Progress;
|
||||
if (_verifyOperation.IsDone)
|
||||
{
|
||||
|
@ -198,22 +181,25 @@ namespace YooAsset
|
|||
{
|
||||
None,
|
||||
CheckAppFootPrint,
|
||||
QueryCachePackageVersion,
|
||||
TryLoadCacheManifest,
|
||||
QueryBuildinPackageVersion,
|
||||
CopyBuildinPackageHash,
|
||||
CopyBuildinManifest,
|
||||
LoadBuildinManifest,
|
||||
StartVerifyOperation,
|
||||
CheckVerifyOperation,
|
||||
VerifyPackage,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private QueryBuildinPackageVersionOperation _buildinPackageVersionQuery;
|
||||
private CopyBuildinManifestOperation _buildinManifestCopy;
|
||||
private LoadBuildinManifestOperation _buildinManifestLoad;
|
||||
private LoadCacheManifestOperation _cacheManifestLoad;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
private QueryBuildinPackageVersionOperation _queryBuildinPackageVersionOp;
|
||||
private QueryCachePackageVersionOperation _queryCachePackageVersionOp;
|
||||
private CopyBuildinPackageHashOperation _copyBuildinPackageHashOp;
|
||||
private CopyBuildinManifestOperation _copyBuildinManifestOp;
|
||||
private LoadBuildinManifestOperation _loadBuildinManifestOp;
|
||||
private LoadCacheManifestOperation _loadCacheManifestOp;
|
||||
private VerifyPackageOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl, string packageName)
|
||||
|
@ -242,25 +228,46 @@ namespace YooAsset
|
|||
appFootPrint.Coverage();
|
||||
YooLogger.Log("Delete manifest files when application foot print dirty !");
|
||||
}
|
||||
_steps = ESteps.QueryCachePackageVersion;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.QueryCachePackageVersion)
|
||||
{
|
||||
if (_queryCachePackageVersionOp == null)
|
||||
{
|
||||
_queryCachePackageVersionOp = new QueryCachePackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_queryCachePackageVersionOp);
|
||||
}
|
||||
|
||||
if (_queryCachePackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryCachePackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.TryLoadCacheManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.QueryBuildinPackageVersion;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.TryLoadCacheManifest)
|
||||
{
|
||||
if (_cacheManifestLoad == null)
|
||||
if (_loadCacheManifestOp == null)
|
||||
{
|
||||
_cacheManifestLoad = new LoadCacheManifestOperation(_packageName);
|
||||
OperationSystem.StartOperation(_cacheManifestLoad);
|
||||
_loadCacheManifestOp = new LoadCacheManifestOperation(_packageName, _queryCachePackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_loadCacheManifestOp);
|
||||
}
|
||||
|
||||
if (_cacheManifestLoad.IsDone == false)
|
||||
if (_loadCacheManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_cacheManifestLoad.Status == EOperationStatus.Succeed)
|
||||
if (_loadCacheManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
InitializedPackageVersion = _cacheManifestLoad.Manifest.PackageVersion;
|
||||
_impl.ActivePatchManifest = _cacheManifestLoad.Manifest;
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
PackageVersion = _loadCacheManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadCacheManifestOp.Manifest;
|
||||
_steps = ESteps.VerifyPackage;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -270,42 +277,64 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.QueryBuildinPackageVersion)
|
||||
{
|
||||
if (_buildinPackageVersionQuery == null)
|
||||
if (_queryBuildinPackageVersionOp == null)
|
||||
{
|
||||
_buildinPackageVersionQuery = new QueryBuildinPackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_buildinPackageVersionQuery);
|
||||
_queryBuildinPackageVersionOp = new QueryBuildinPackageVersionOperation(_packageName);
|
||||
OperationSystem.StartOperation(_queryBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_buildinPackageVersionQuery.IsDone == false)
|
||||
if (_queryBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
// 注意:为了兼容MOD模式,初始化动态新增的包裹的时候,如果内置清单不存在也不需要报错!
|
||||
if (_buildinPackageVersionQuery.Status == EOperationStatus.Succeed)
|
||||
if (_queryBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CopyBuildinPackageHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
string error = _queryBuildinPackageVersionOp.Error;
|
||||
YooLogger.Log($"Failed to load buildin package version file : {error}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CopyBuildinPackageHash)
|
||||
{
|
||||
if (_copyBuildinPackageHashOp == null)
|
||||
{
|
||||
_copyBuildinPackageHashOp = new CopyBuildinPackageHashOperation(_packageName, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_copyBuildinPackageHashOp);
|
||||
}
|
||||
|
||||
if (_copyBuildinPackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_copyBuildinPackageHashOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CopyBuildinManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
string error = _buildinPackageVersionQuery.Error;
|
||||
YooLogger.Log($"Failed to load buildin package version file : {error}");
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _copyBuildinPackageHashOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CopyBuildinManifest)
|
||||
{
|
||||
if (_buildinManifestCopy == null)
|
||||
if (_copyBuildinManifestOp == null)
|
||||
{
|
||||
_buildinManifestCopy = new CopyBuildinManifestOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
OperationSystem.StartOperation(_buildinManifestCopy);
|
||||
_copyBuildinManifestOp = new CopyBuildinManifestOperation(_packageName, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_copyBuildinManifestOp);
|
||||
}
|
||||
|
||||
Progress = _buildinManifestCopy.Progress;
|
||||
if (_buildinManifestCopy.IsDone == false)
|
||||
if (_copyBuildinManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_buildinManifestCopy.Status == EOperationStatus.Succeed)
|
||||
if (_copyBuildinManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadBuildinManifest;
|
||||
}
|
||||
|
@ -313,45 +342,44 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _buildinManifestCopy.Error;
|
||||
Error = _copyBuildinManifestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuildinManifest)
|
||||
{
|
||||
if (_buildinManifestLoad == null)
|
||||
if (_loadBuildinManifestOp == null)
|
||||
{
|
||||
_buildinManifestLoad = new LoadBuildinManifestOperation(_packageName, _buildinPackageVersionQuery.Version);
|
||||
OperationSystem.StartOperation(_buildinManifestLoad);
|
||||
_loadBuildinManifestOp = new LoadBuildinManifestOperation(_packageName, _queryBuildinPackageVersionOp.PackageVersion);
|
||||
OperationSystem.StartOperation(_loadBuildinManifestOp);
|
||||
}
|
||||
|
||||
Progress = _buildinManifestLoad.Progress;
|
||||
if (_buildinManifestLoad.IsDone == false)
|
||||
Progress = _loadBuildinManifestOp.Progress;
|
||||
if (_loadBuildinManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_buildinManifestLoad.Status == EOperationStatus.Succeed)
|
||||
if (_loadBuildinManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
InitializedPackageVersion = _buildinManifestLoad.Manifest.PackageVersion;
|
||||
_impl.ActivePatchManifest = _buildinManifestLoad.Manifest;
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
PackageVersion = _loadBuildinManifestOp.Manifest.PackageVersion;
|
||||
_impl.ActiveManifest = _loadBuildinManifestOp.Manifest;
|
||||
_steps = ESteps.VerifyPackage;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _buildinManifestLoad.Error;
|
||||
Error = _loadBuildinManifestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
if (_steps == ESteps.VerifyPackage)
|
||||
{
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_impl.ActivePatchManifest, _impl);
|
||||
if (_verifyOperation == null)
|
||||
{
|
||||
_verifyOperation = VerifyPackageOperation.CreateOperation(_impl.ActiveManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckVerifyOperation)
|
||||
{
|
||||
Progress = _verifyOperation.Progress;
|
||||
if (_verifyOperation.IsDone)
|
||||
{
|
||||
|
@ -362,7 +390,6 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序水印
|
||||
/// </summary>
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置补丁清单复制器
|
||||
/// </summary>
|
||||
internal class CopyBuildinManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CopyBuildinManifest,
|
||||
CheckCopyBuildinManifest,
|
||||
CopyBuildinManifestFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
|
@ -19,7 +15,6 @@ namespace YooAsset
|
|||
private UnityWebFileRequester _downloader;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public CopyBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
{
|
||||
_buildinPackageName = buildinPackageName;
|
||||
|
@ -27,26 +22,25 @@ namespace YooAsset
|
|||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.CopyBuildinManifest;
|
||||
_steps = ESteps.CopyBuildinManifestFile;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CopyBuildinManifest)
|
||||
if (_steps == ESteps.CopyBuildinManifestFile)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_buildinPackageName);
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
|
||||
if (_downloader == null)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_buildinPackageName, _buildinPackageVersion);
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
|
||||
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||
_downloader = new UnityWebFileRequester();
|
||||
_downloader.SendRequest(url, savePath);
|
||||
_steps = ESteps.CheckCopyBuildinManifest;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckCopyBuildinManifest)
|
||||
{
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CopyBuildinPackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CopyBuildinPackageHashFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _buildinPackageName;
|
||||
private readonly string _buildinPackageVersion;
|
||||
private UnityWebFileRequester _downloader;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public CopyBuildinPackageHashOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
{
|
||||
_buildinPackageName = buildinPackageName;
|
||||
_buildinPackageVersion = buildinPackageVersion;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.CopyBuildinPackageHashFile;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CopyBuildinPackageHashFile)
|
||||
{
|
||||
if (_downloader == null)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCachePackageHashFilePath(_buildinPackageName, _buildinPackageVersion);
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_buildinPackageName, _buildinPackageVersion);
|
||||
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||
_downloader = new UnityWebFileRequester();
|
||||
_downloader.SendRequest(url, savePath);
|
||||
}
|
||||
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (_downloader.HasError())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloader.GetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
||||
_downloader.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bb073431e4f3b434e8431b3a8a808dfb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -17,13 +17,17 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
private readonly BufferReader _buffer;
|
||||
private int _patchAssetCount;
|
||||
private int _patchBundleCount;
|
||||
private int _progressTotalValue;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 解析的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
|
||||
public DeserializeManifestOperation(byte[] binaryData)
|
||||
{
|
||||
_buffer = new BufferReader(binaryData);
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DownloadManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
DownloadPackageHash,
|
||||
DownloadManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private static int RequestCount = 0;
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private UnityWebFileRequester _downloader1;
|
||||
private UnityWebFileRequester _downloader2;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DownloadManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageName = packageName;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
RequestCount++;
|
||||
_steps = ESteps.DownloadPackageHash;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.DownloadPackageHash)
|
||||
{
|
||||
if (_downloader1 == null)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCachePackageHashFilePath(_packageName, _packageVersion);
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion);
|
||||
string webURL = GetDownloadRequestURL(fileName);
|
||||
YooLogger.Log($"Beginning to download package hash file : {webURL}");
|
||||
_downloader1 = new UnityWebFileRequester();
|
||||
_downloader1.SendRequest(webURL, savePath, _timeout);
|
||||
}
|
||||
|
||||
_downloader1.CheckTimeout();
|
||||
if (_downloader1.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (_downloader1.HasError())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloader1.GetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.DownloadManifest;
|
||||
}
|
||||
|
||||
_downloader1.Dispose();
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadManifest)
|
||||
{
|
||||
if (_downloader2 == null)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName, _packageVersion);
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
||||
string webURL = GetDownloadRequestURL(fileName);
|
||||
YooLogger.Log($"Beginning to download manifest file : {webURL}");
|
||||
_downloader2 = new UnityWebFileRequester();
|
||||
_downloader2.SendRequest(webURL, savePath, _timeout);
|
||||
}
|
||||
|
||||
_downloader2.CheckTimeout();
|
||||
if (_downloader2.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (_downloader2.HasError())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloader2.GetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
||||
_downloader2.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetDownloadRequestURL(string fileName)
|
||||
{
|
||||
// 轮流返回请求地址
|
||||
if (RequestCount % 2 == 0)
|
||||
return _impl.GetPatchDownloadFallbackURL(fileName);
|
||||
else
|
||||
return _impl.GetPatchDownloadMainURL(fileName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fccaa9437207a174d858ce44f14f5a03
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,16 +1,12 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置补丁清单加载器
|
||||
/// </summary>
|
||||
internal class LoadBuildinManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadBuildinManifest,
|
||||
CheckLoadBuildinManifest,
|
||||
CheckDeserializeManifest,
|
||||
Done,
|
||||
}
|
||||
|
@ -22,7 +18,7 @@ namespace YooAsset
|
|||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 加载结果
|
||||
/// 加载的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
|
||||
|
@ -43,16 +39,15 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.LoadBuildinManifest)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
|
||||
if (_downloader == null)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
|
||||
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||
_downloader = new UnityWebDataRequester();
|
||||
_downloader.SendRequest(url);
|
||||
_steps = ESteps.CheckLoadBuildinManifest;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckLoadBuildinManifest)
|
||||
{
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
||||
|
|
|
@ -2,54 +2,97 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 沙盒补丁清单加载器
|
||||
/// </summary>
|
||||
internal class LoadCacheManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadCacheManifestFile,
|
||||
QueryCachePackageHash,
|
||||
VerifyFileHash,
|
||||
LoadCacheManifest,
|
||||
CheckDeserializeManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageVersion;
|
||||
private QueryCachePackageHashOperation _queryCachePackageHashOp;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private string _manifestFilePath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 加载结果
|
||||
/// 加载的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public LoadCacheManifestOperation(string packageName)
|
||||
public LoadCacheManifestOperation(string packageName, string packageVersion)
|
||||
{
|
||||
_packageName = packageName;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.LoadCacheManifestFile;
|
||||
_steps = ESteps.QueryCachePackageHash;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadCacheManifestFile)
|
||||
if (_steps == ESteps.QueryCachePackageHash)
|
||||
{
|
||||
_manifestFilePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
if (_queryCachePackageHashOp == null)
|
||||
{
|
||||
_queryCachePackageHashOp = new QueryCachePackageHashOperation(_packageName, _packageVersion);
|
||||
OperationSystem.StartOperation(_queryCachePackageHashOp);
|
||||
}
|
||||
|
||||
if (_queryCachePackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryCachePackageHashOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.VerifyFileHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _queryCachePackageHashOp.Error;
|
||||
ClearCacheFile();
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.VerifyFileHash)
|
||||
{
|
||||
_manifestFilePath = PersistentHelper.GetCacheManifestFilePath(_packageName, _packageVersion);
|
||||
if (File.Exists(_manifestFilePath) == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Manifest file not found : {_manifestFilePath}";
|
||||
Error = $"Not found cache manifest file : {_manifestFilePath}";
|
||||
ClearCacheFile();
|
||||
return;
|
||||
}
|
||||
|
||||
string fileHash = HashUtility.FileMD5(_manifestFilePath);
|
||||
if (fileHash != _queryCachePackageHashOp.PackageHash)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to verify cache manifest file hash !";
|
||||
ClearCacheFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadCacheManifest;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadCacheManifest)
|
||||
{
|
||||
byte[] bytesData = File.ReadAllBytes(_manifestFilePath);
|
||||
_deserializer = new DeserializeManifestOperation(bytesData);
|
||||
OperationSystem.StartOperation(_deserializer);
|
||||
|
@ -73,15 +116,25 @@ namespace YooAsset
|
|||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
ClearCacheFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 注意:如果加载沙盒内的清单报错,为了避免流程被卡住,我们主动把损坏的文件删除。
|
||||
private void ClearCacheFile()
|
||||
{
|
||||
// 注意:如果加载沙盒内的清单报错,为了避免流程被卡住,主动把损坏的文件删除。
|
||||
if (File.Exists(_manifestFilePath))
|
||||
{
|
||||
YooLogger.Warning($"Failed to load cache manifest file : {Error}");
|
||||
YooLogger.Warning($"Invalid cache manifest file have been removed : {_manifestFilePath}");
|
||||
File.Delete(_manifestFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
string hashFilePath = PersistentHelper.GetCachePackageHashFilePath(_packageName, _packageVersion);
|
||||
if (File.Exists(hashFilePath))
|
||||
{
|
||||
File.Delete(hashFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadEditorManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadEditorManifest,
|
||||
CheckDeserializeManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _manifestFilePath;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 加载的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public LoadEditorManifestOperation(string manifestFilePath)
|
||||
{
|
||||
_manifestFilePath = manifestFilePath;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.LoadEditorManifest;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadEditorManifest)
|
||||
{
|
||||
if (File.Exists(_manifestFilePath) == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Not found simulation manifest file : {_manifestFilePath}";
|
||||
return;
|
||||
}
|
||||
|
||||
YooLogger.Log($"Load editor manifest file : {_manifestFilePath}");
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(_manifestFilePath);
|
||||
_deserializer = new DeserializeManifestOperation(bytesData);
|
||||
OperationSystem.StartOperation(_deserializer);
|
||||
_steps = ESteps.CheckDeserializeManifest;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckDeserializeManifest)
|
||||
{
|
||||
Progress = _deserializer.Progress;
|
||||
if (_deserializer.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
Manifest = _deserializer.Manifest;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 246df4d20b431c648a0821231a805e6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,16 +1,12 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置补丁清单版本查询器
|
||||
/// </summary>
|
||||
internal class QueryBuildinPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadPackageVersion,
|
||||
CheckLoadPackageVersion,
|
||||
LoadBuildinPackageVersionFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
|
@ -19,9 +15,9 @@ namespace YooAsset
|
|||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 内置包裹版本
|
||||
/// 包裹版本
|
||||
/// </summary>
|
||||
public string Version { private set; get; }
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
public QueryBuildinPackageVersionOperation(string packageName)
|
||||
|
@ -30,25 +26,24 @@ namespace YooAsset
|
|||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.LoadPackageVersion;
|
||||
_steps = ESteps.LoadBuildinPackageVersionFile;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadPackageVersion)
|
||||
if (_steps == ESteps.LoadBuildinPackageVersionFile)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
|
||||
if (_downloader == null)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
|
||||
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||
_downloader = new UnityWebDataRequester();
|
||||
_downloader.SendRequest(url);
|
||||
_steps = ESteps.CheckLoadPackageVersion;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckLoadPackageVersion)
|
||||
{
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
||||
|
@ -60,8 +55,8 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
Version = _downloader.GetText();
|
||||
if (string.IsNullOrEmpty(Version))
|
||||
PackageVersion = _downloader.GetText();
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class QueryCachePackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadCachePackageHashFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageVersion;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹哈希值
|
||||
/// </summary>
|
||||
public string PackageHash { private set; get; }
|
||||
|
||||
|
||||
public QueryCachePackageHashOperation(string packageName, string packageVersion)
|
||||
{
|
||||
_packageName = packageName;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.LoadCachePackageHashFile;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadCachePackageHashFile)
|
||||
{
|
||||
string filePath = PersistentHelper.GetCachePackageHashFilePath(_packageName, _packageVersion);
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Cache package hash file not found : {filePath}";
|
||||
return;
|
||||
}
|
||||
|
||||
PackageHash = FileUtility.ReadAllText(filePath);
|
||||
if (string.IsNullOrEmpty(PackageHash))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Cache package hash file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 60db6a6586340664ab7e9f85cec0eef4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,62 @@
|
|||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class QueryCachePackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadCachePackageVersionFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _packageName;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
public QueryCachePackageVersionOperation(string packageName)
|
||||
{
|
||||
_packageName = packageName;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.LoadCachePackageVersionFile;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadCachePackageVersionFile)
|
||||
{
|
||||
string filePath = PersistentHelper.GetCachePackageVersionFilePath(_packageName);
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Cache package version file not found : {filePath}";
|
||||
return;
|
||||
}
|
||||
|
||||
PackageVersion = FileUtility.ReadAllText(filePath);
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Cache package version file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 29a2cbdd051ba1247a24693d56cdc2c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -6,20 +6,17 @@ using System.Threading;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证
|
||||
/// </summary>
|
||||
internal abstract class VerifyCacheFilesOperation : AsyncOperationBase
|
||||
internal abstract class VerifyPackageOperation : AsyncOperationBase
|
||||
{
|
||||
public List<VerifyInfo> VerifySuccessList { protected set; get; }
|
||||
public List<VerifyInfo> VerifyFailList { protected set; get; }
|
||||
|
||||
public static VerifyCacheFilesOperation CreateOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
public static VerifyPackageOperation CreateOperation(PatchManifest manifest, IPlayModeServices playModeServices)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
VerifyCacheFilesOperation operation = new VerifyCacheFilesWithoutThreadOperation(patchManifest, playModeServices);
|
||||
VerifyPackageOperation operation = new VerifyPackageWithoutThreadOperation(manifest, playModeServices);
|
||||
#else
|
||||
VerifyCacheFilesOperation operation = new VerifyCacheFilesWithThreadOperation(patchManifest, playModeServices);
|
||||
VerifyPackageOperation operation = new VerifyPackageWithThreadOperation(manifest, playModeServices);
|
||||
#endif
|
||||
return operation;
|
||||
}
|
||||
|
@ -28,7 +25,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 本地缓存文件验证(线程版)
|
||||
/// </summary>
|
||||
internal class VerifyCacheFilesWithThreadOperation : VerifyCacheFilesOperation
|
||||
internal class VerifyPackageWithThreadOperation : VerifyPackageOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -39,7 +36,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly PatchManifest _patchManifest;
|
||||
private readonly PatchManifest _manifest;
|
||||
private readonly IPlayModeServices _playModeServices;
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private List<VerifyInfo> _waitingList;
|
||||
|
@ -49,9 +46,9 @@ namespace YooAsset
|
|||
private float _verifyStartTime;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public VerifyCacheFilesWithThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
public VerifyPackageWithThreadOperation(PatchManifest manifest, IPlayModeServices playModeServices)
|
||||
{
|
||||
_patchManifest = patchManifest;
|
||||
_manifest = manifest;
|
||||
_playModeServices = playModeServices;
|
||||
}
|
||||
internal override void Start()
|
||||
|
@ -66,7 +63,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.InitVerify)
|
||||
{
|
||||
int bundleCount = _patchManifest.BundleList.Count;
|
||||
int bundleCount = _manifest.BundleList.Count;
|
||||
VerifySuccessList = new List<VerifyInfo>(bundleCount);
|
||||
VerifyFailList = new List<VerifyInfo>(bundleCount);
|
||||
|
||||
|
@ -85,7 +82,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.PrepareVerify)
|
||||
{
|
||||
foreach (var patchBundle in _patchManifest.BundleList)
|
||||
foreach (var patchBundle in _manifest.BundleList)
|
||||
{
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
@ -175,7 +172,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 本地缓存文件验证(非线程版)
|
||||
/// </summary>
|
||||
internal class VerifyCacheFilesWithoutThreadOperation : VerifyCacheFilesOperation
|
||||
internal class VerifyPackageWithoutThreadOperation : VerifyPackageOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -186,7 +183,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly PatchManifest _patchManifest;
|
||||
private readonly PatchManifest _manifest;
|
||||
private readonly IPlayModeServices _playModeServices;
|
||||
private List<VerifyInfo> _waitingList;
|
||||
private List<VerifyInfo> _verifyingList;
|
||||
|
@ -195,9 +192,9 @@ namespace YooAsset
|
|||
private float _verifyStartTime;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public VerifyCacheFilesWithoutThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||
public VerifyPackageWithoutThreadOperation(PatchManifest manifest, IPlayModeServices playModeServices)
|
||||
{
|
||||
_patchManifest = patchManifest;
|
||||
_manifest = manifest;
|
||||
_playModeServices = playModeServices;
|
||||
}
|
||||
internal override void Start()
|
||||
|
@ -212,7 +209,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.InitVerify)
|
||||
{
|
||||
int bundleCount = _patchManifest.BundleList.Count;
|
||||
int bundleCount = _manifest.BundleList.Count;
|
||||
VerifySuccessList = new List<VerifyInfo>(bundleCount);
|
||||
VerifyFailList = new List<VerifyInfo>(bundleCount);
|
||||
|
||||
|
@ -227,7 +224,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.PrepareVerify)
|
||||
{
|
||||
foreach (var patchBundle in _patchManifest.BundleList)
|
||||
foreach (var patchBundle in _manifest.BundleList)
|
||||
{
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
|
@ -10,20 +10,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 发现了新的清单
|
||||
/// </summary>
|
||||
public bool FoundNewManifest { protected set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 手动保存清单文件
|
||||
/// </summary>
|
||||
public virtual void SaveManifestFile() { }
|
||||
|
||||
/// <summary>
|
||||
/// 还原补丁清单
|
||||
/// </summary>
|
||||
public virtual void RevertManifest() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -69,177 +55,134 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
TryLoadCacheHash,
|
||||
DownloadWebHash,
|
||||
CheckDownloadWebHash,
|
||||
DownloadWebManifest,
|
||||
CheckDownloadWebManifest,
|
||||
CheckDeserializeWebManifest,
|
||||
StartVerifyOperation,
|
||||
CheckVerifyOperation,
|
||||
CheckActiveManifest,
|
||||
TryLoadCacheManifest,
|
||||
DownloadManifest,
|
||||
LoadCacheManifest,
|
||||
CheckDeserializeManifest,
|
||||
VerifyPackage,
|
||||
Done,
|
||||
}
|
||||
|
||||
private static int RequestCount = 0;
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageVersion;
|
||||
private readonly bool _autoSaveManifestFile;
|
||||
private readonly int _timeout;
|
||||
private UnityWebDataRequester _downloader1;
|
||||
private UnityWebDataRequester _downloader2;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private VerifyCacheFilesOperation _verifyOperation;
|
||||
|
||||
internal PatchManifest _prePatchManifest;
|
||||
private string _cacheManifestHash;
|
||||
private byte[] _fileBytesData = null;
|
||||
private LoadCacheManifestOperation _tryLoadCacheManifestOp;
|
||||
private LoadCacheManifestOperation _loadCacheManifestOp;
|
||||
private DownloadManifestOperation _downloadManifestOp;
|
||||
private VerifyPackageOperation _verifyOperation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
|
||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageName = packageName;
|
||||
_packageVersion = packageVersion;
|
||||
_autoSaveManifestFile = autoSaveManifestFile;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
RequestCount++;
|
||||
_steps = ESteps.TryLoadCacheHash;
|
||||
_steps = ESteps.CheckActiveManifest;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.TryLoadCacheHash)
|
||||
if (_steps == ESteps.CheckActiveManifest)
|
||||
{
|
||||
string filePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
if (File.Exists(filePath))
|
||||
// 检测当前激活的清单对象
|
||||
if (_impl.ActiveManifest != null)
|
||||
{
|
||||
_cacheManifestHash = HashUtility.FileMD5(filePath);
|
||||
_steps = ESteps.DownloadWebHash;
|
||||
}
|
||||
else
|
||||
if (_impl.ActiveManifest.PackageVersion == _packageVersion)
|
||||
{
|
||||
_steps = ESteps.DownloadWebManifest;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadWebHash)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(_packageName, _packageVersion);
|
||||
string webURL = GetPatchManifestRequestURL(fileName);
|
||||
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
|
||||
_downloader1 = new UnityWebDataRequester();
|
||||
_downloader1.SendRequest(webURL, _timeout);
|
||||
_steps = ESteps.CheckDownloadWebHash;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckDownloadWebHash)
|
||||
{
|
||||
if (_downloader1.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (_downloader1.HasError())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloader1.GetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
string webManifestHash = _downloader1.GetText();
|
||||
if (_cacheManifestHash == webManifestHash)
|
||||
{
|
||||
YooLogger.Log($"Not found new package : {_packageName}");
|
||||
FoundNewManifest = false;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Log($"Package {_packageName} is change : {_cacheManifestHash} -> {webManifestHash}");
|
||||
FoundNewManifest = true;
|
||||
_steps = ESteps.DownloadWebManifest;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_downloader1.Dispose();
|
||||
_steps = ESteps.TryLoadCacheManifest;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.DownloadWebManifest)
|
||||
if (_steps == ESteps.TryLoadCacheManifest)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestBinaryFileName(_packageName, _packageVersion);
|
||||
string webURL = GetPatchManifestRequestURL(fileName);
|
||||
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
||||
_downloader2 = new UnityWebDataRequester();
|
||||
_downloader2.SendRequest(webURL, _timeout);
|
||||
_steps = ESteps.CheckDownloadWebManifest;
|
||||
if (_tryLoadCacheManifestOp == null)
|
||||
{
|
||||
_tryLoadCacheManifestOp = new LoadCacheManifestOperation(_packageName, _packageVersion);
|
||||
OperationSystem.StartOperation(_tryLoadCacheManifestOp);
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckDownloadWebManifest)
|
||||
{
|
||||
if (_downloader2.IsDone() == false)
|
||||
if (_tryLoadCacheManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_downloader2.HasError())
|
||||
if (_tryLoadCacheManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloader2.GetError();
|
||||
_impl.ActiveManifest = _tryLoadCacheManifestOp.Manifest;
|
||||
_steps = ESteps.VerifyPackage;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytesData = _downloader2.GetData();
|
||||
if (_autoSaveManifestFile)
|
||||
{
|
||||
SaveManifestFileInternal(bytesData);
|
||||
_steps = ESteps.DownloadManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fileBytesData = bytesData;
|
||||
}
|
||||
|
||||
// 解析二进制数据
|
||||
_deserializer = new DeserializeManifestOperation(bytesData);
|
||||
OperationSystem.StartOperation(_deserializer);
|
||||
_steps = ESteps.CheckDeserializeWebManifest;
|
||||
}
|
||||
|
||||
_downloader2.Dispose();
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckDeserializeWebManifest)
|
||||
if (_steps == ESteps.DownloadManifest)
|
||||
{
|
||||
Progress = _deserializer.Progress;
|
||||
if (_deserializer.IsDone == false)
|
||||
if (_downloadManifestOp == null)
|
||||
{
|
||||
_downloadManifestOp = new DownloadManifestOperation(_impl, _packageName, _packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_downloadManifestOp);
|
||||
}
|
||||
|
||||
if (_downloadManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
if (_downloadManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_prePatchManifest = _impl.ActivePatchManifest;
|
||||
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||
_steps = ESteps.StartVerifyOperation;
|
||||
_steps = ESteps.LoadCacheManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
Error = _downloadManifestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.StartVerifyOperation)
|
||||
if (_steps == ESteps.LoadCacheManifest)
|
||||
{
|
||||
_verifyOperation = VerifyCacheFilesOperation.CreateOperation(_deserializer.Manifest, _impl);
|
||||
if (_loadCacheManifestOp == null)
|
||||
{
|
||||
_loadCacheManifestOp = new LoadCacheManifestOperation(_packageName, _packageVersion);
|
||||
OperationSystem.StartOperation(_loadCacheManifestOp);
|
||||
}
|
||||
|
||||
if (_loadCacheManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadCacheManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_impl.ActiveManifest = _loadCacheManifestOp.Manifest;
|
||||
_steps = ESteps.VerifyPackage;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadCacheManifestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.VerifyPackage)
|
||||
{
|
||||
if (_verifyOperation == null)
|
||||
{
|
||||
_verifyOperation = VerifyPackageOperation.CreateOperation(_impl.ActiveManifest, _impl);
|
||||
OperationSystem.StartOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyOperation;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckVerifyOperation)
|
||||
{
|
||||
Progress = _verifyOperation.Progress;
|
||||
if (_verifyOperation.IsDone)
|
||||
{
|
||||
|
@ -248,61 +191,5 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动保存清单文件
|
||||
/// </summary>
|
||||
public override void SaveManifestFile()
|
||||
{
|
||||
if (IsDone == false)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(UpdatePackageManifestOperation)} is not done !");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_fileBytesData != null)
|
||||
{
|
||||
SaveManifestFileInternal(_fileBytesData);
|
||||
_fileBytesData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 还原补丁清单
|
||||
/// </summary>
|
||||
public override void RevertManifest()
|
||||
{
|
||||
if (IsDone == false)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(UpdatePackageManifestOperation)} is not done !");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_prePatchManifest != null)
|
||||
{
|
||||
_impl.ActivePatchManifest = _prePatchManifest;
|
||||
_prePatchManifest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveManifestFileInternal(byte[] bytesData)
|
||||
{
|
||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||
FileUtility.CreateFile(savePath, bytesData);
|
||||
}
|
||||
private string GetPatchManifestRequestURL(string fileName)
|
||||
{
|
||||
// 轮流返回请求地址
|
||||
if (RequestCount % 2 == 0)
|
||||
return _impl.GetPatchDownloadFallbackURL(fileName);
|
||||
else
|
||||
return _impl.GetPatchDownloadMainURL(fileName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,8 +51,7 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadPackageVersion,
|
||||
CheckLoadPackageVersion,
|
||||
DownloadPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
|
@ -74,25 +73,24 @@ namespace YooAsset
|
|||
internal override void Start()
|
||||
{
|
||||
RequestCount++;
|
||||
_steps = ESteps.LoadPackageVersion;
|
||||
_steps = ESteps.DownloadPackageVersion;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadPackageVersion)
|
||||
if (_steps == ESteps.DownloadPackageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
|
||||
if (_downloader == null)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
|
||||
string webURL = GetPackageVersionRequestURL(fileName);
|
||||
YooLogger.Log($"Beginning to request package version : {webURL}");
|
||||
_downloader = new UnityWebDataRequester();
|
||||
_downloader.SendRequest(webURL, _timeout);
|
||||
_steps = ESteps.CheckLoadPackageVersion;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckLoadPackageVersion)
|
||||
{
|
||||
Progress = _downloader.Progress();
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
|||
{
|
||||
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
|
||||
{
|
||||
private PatchManifest _activePatchManifest;
|
||||
private PatchManifest _activeManifest;
|
||||
private string _packageName;
|
||||
private bool _locationToLower;
|
||||
|
||||
|
@ -23,24 +23,18 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PatchManifest ActivePatchManifest
|
||||
public PatchManifest ActiveManifest
|
||||
{
|
||||
set
|
||||
{
|
||||
_activePatchManifest = value;
|
||||
_activePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||
_activeManifest = value;
|
||||
_activeManifest.InitAssetPathMapping(_locationToLower);
|
||||
}
|
||||
get
|
||||
{
|
||||
return _activePatchManifest;
|
||||
return _activeManifest;
|
||||
}
|
||||
}
|
||||
public string GetPackageVersion()
|
||||
{
|
||||
if (_activePatchManifest == null)
|
||||
return string.Empty;
|
||||
return _activePatchManifest.PackageVersion;
|
||||
}
|
||||
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||
{
|
||||
return true;
|
||||
|
@ -52,7 +46,7 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
||||
OperationSystem.StartOperation(operation);
|
||||
|
@ -95,7 +89,7 @@ namespace YooAsset
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
@ -105,22 +99,22 @@ namespace YooAsset
|
|||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return _activePatchManifest.GetAssetsInfoByTags(tags);
|
||||
return _activeManifest.GetAssetsInfoByTags(tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (_activePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
if (_activeManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return _activePatchManifest.MappingToAssetPath(location);
|
||||
return _activeManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return _activePatchManifest.TryMappingToAssetPath(location);
|
||||
return _activeManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
|
@ -128,11 +122,11 @@ namespace YooAsset
|
|||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _activePatchManifest.IsIncludeBundleFile(fileName);
|
||||
return _activeManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _activePatchManifest != null;
|
||||
return _activeManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
|||
{
|
||||
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices
|
||||
{
|
||||
private PatchManifest _activePatchManifest;
|
||||
private PatchManifest _activeManifest;
|
||||
|
||||
// 参数相关
|
||||
private string _packageName;
|
||||
|
@ -80,24 +80,19 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PatchManifest ActivePatchManifest
|
||||
public PatchManifest ActiveManifest
|
||||
{
|
||||
set
|
||||
{
|
||||
_activePatchManifest = value;
|
||||
_activePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||
_activeManifest = value;
|
||||
_activeManifest.InitAssetPathMapping(_locationToLower);
|
||||
PersistentHelper.SaveCachePackageVersionFile(_packageName, _activeManifest.PackageVersion);
|
||||
}
|
||||
get
|
||||
{
|
||||
return _activePatchManifest;
|
||||
return _activeManifest;
|
||||
}
|
||||
}
|
||||
public string GetPackageVersion()
|
||||
{
|
||||
if (_activePatchManifest == null)
|
||||
return string.Empty;
|
||||
return _activePatchManifest.PackageVersion;
|
||||
}
|
||||
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||
{
|
||||
return _queryServices.QueryStreamingAssets(patchBundle.FileName);
|
||||
|
@ -109,9 +104,9 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, autoSaveManifestFile, timeout);
|
||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -124,11 +119,11 @@ namespace YooAsset
|
|||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll(_activePatchManifest);
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll(_activeManifest);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetDownloadListByAll(PatchManifest patchManifest)
|
||||
public List<BundleInfo> GetDownloadListByAll(PatchManifest patchManifest)
|
||||
{
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
|
@ -149,11 +144,11 @@ namespace YooAsset
|
|||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(_activePatchManifest, tags);
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(_activeManifest, tags);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetDownloadListByTags(PatchManifest patchManifest, string[] tags)
|
||||
public List<BundleInfo> GetDownloadListByTags(PatchManifest patchManifest, string[] tags)
|
||||
{
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
|
@ -186,7 +181,7 @@ namespace YooAsset
|
|||
|
||||
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(_activePatchManifest, assetInfos);
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(_activeManifest, assetInfos);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -235,7 +230,7 @@ namespace YooAsset
|
|||
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll(_activePatchManifest);
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll(_activeManifest);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -259,7 +254,7 @@ namespace YooAsset
|
|||
|
||||
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(_activePatchManifest, tags);
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(_activeManifest, tags);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -315,7 +310,7 @@ namespace YooAsset
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(patchBundle);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
|
@ -324,7 +319,7 @@ namespace YooAsset
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var depends = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var patchBundle in depends)
|
||||
{
|
||||
|
@ -335,22 +330,22 @@ namespace YooAsset
|
|||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return _activePatchManifest.GetAssetsInfoByTags(tags);
|
||||
return _activeManifest.GetAssetsInfoByTags(tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (_activePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
if (_activeManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return _activePatchManifest.MappingToAssetPath(location);
|
||||
return _activeManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return _activePatchManifest.TryMappingToAssetPath(location);
|
||||
return _activeManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
|
@ -358,11 +353,11 @@ namespace YooAsset
|
|||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _activePatchManifest.IsIncludeBundleFile(fileName);
|
||||
return _activeManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _activePatchManifest != null;
|
||||
return _activeManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
|||
{
|
||||
internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices
|
||||
{
|
||||
private PatchManifest _activePatchManifest;
|
||||
private PatchManifest _activeManifest;
|
||||
private string _packageName;
|
||||
private bool _locationToLower;
|
||||
|
||||
|
@ -23,24 +23,18 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PatchManifest ActivePatchManifest
|
||||
public PatchManifest ActiveManifest
|
||||
{
|
||||
set
|
||||
{
|
||||
_activePatchManifest = value;
|
||||
_activePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||
_activeManifest = value;
|
||||
_activeManifest.InitAssetPathMapping(_locationToLower);
|
||||
}
|
||||
get
|
||||
{
|
||||
return _activePatchManifest;
|
||||
return _activeManifest;
|
||||
}
|
||||
}
|
||||
public string GetPackageVersion()
|
||||
{
|
||||
if (_activePatchManifest == null)
|
||||
return string.Empty;
|
||||
return _activePatchManifest.PackageVersion;
|
||||
}
|
||||
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||
{
|
||||
return true;
|
||||
|
@ -52,7 +46,7 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout)
|
||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
||||
OperationSystem.StartOperation(operation);
|
||||
|
@ -113,7 +107,7 @@ namespace YooAsset
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(patchBundle);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
|
@ -122,7 +116,7 @@ namespace YooAsset
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var depends = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var patchBundle in depends)
|
||||
{
|
||||
|
@ -133,22 +127,22 @@ namespace YooAsset
|
|||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return _activePatchManifest.GetAssetsInfoByTags(tags);
|
||||
return _activeManifest.GetAssetsInfoByTags(tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (_activePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
if (_activeManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return _activePatchManifest.MappingToAssetPath(location);
|
||||
return _activeManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return _activePatchManifest.TryMappingToAssetPath(location);
|
||||
return _activeManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
|
@ -156,11 +150,11 @@ namespace YooAsset
|
|||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _activePatchManifest.IsIncludeBundleFile(fileName);
|
||||
return _activeManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _activePatchManifest != null;
|
||||
return _activeManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -6,12 +6,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 激活的清单
|
||||
/// </summary>
|
||||
PatchManifest ActivePatchManifest { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取激活包裹的版本信息
|
||||
/// </summary>
|
||||
string GetPackageVersion();
|
||||
PatchManifest ActiveManifest { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为内置资源文件
|
||||
|
@ -26,19 +21,19 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 向网络端请求并更新补丁清单
|
||||
/// </summary>
|
||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifestFile, int timeout);
|
||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// 检查包裹内容的完整性
|
||||
/// </summary>
|
||||
CheckContentsIntegrityOperation CheckContentsIntegrityAsync();
|
||||
|
||||
// 下载相关方法
|
||||
// 下载相关
|
||||
PatchDownloaderOperation CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
|
||||
// 解压相关方法
|
||||
// 解压相关
|
||||
PatchUnpackerOperation CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
}
|
||||
|
|
|
@ -41,41 +41,33 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁清单文件不带版本号的名称
|
||||
/// 获取清单文件完整名称
|
||||
/// </summary>
|
||||
public static string GetPatchManifestFileNameWithoutVersion(string packageName)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}.bytes";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁清单文件完整名称
|
||||
/// </summary>
|
||||
public static string GetPatchManifestBinaryFileName(string packageName, string packageVersion)
|
||||
public static string GetManifestBinaryFileName(string packageName, string packageVersion)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.bytes";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁清单文件完整名称
|
||||
/// 获取清单文件完整名称
|
||||
/// </summary>
|
||||
public static string GetPatchManifestJsonFileName(string packageName, string packageVersion)
|
||||
public static string GetManifestJsonFileName(string packageName, string packageVersion)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.json";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁清单哈希文件完整名称
|
||||
/// 获取包裹的哈希文件完整名称
|
||||
/// </summary>
|
||||
public static string GetPatchManifestHashFileName(string packageName, string packageVersion)
|
||||
public static string GetPackageHashFileName(string packageName, string packageVersion)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.hash";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补丁清单版本文件完整名称
|
||||
/// 获取包裹的版本文件完整名称
|
||||
/// </summary>
|
||||
public static string GetPatchManifestVersionFileName(string packageName)
|
||||
public static string GetPackageVersionFileName(string packageName)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}.version";
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ namespace YooAsset
|
|||
private const string ManifestFolderName = "ManifestFiles";
|
||||
private const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除沙盒总目录
|
||||
/// </summary>
|
||||
|
@ -117,6 +118,7 @@ namespace YooAsset
|
|||
Directory.Delete(root, true);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存文件夹路径
|
||||
/// </summary>
|
||||
|
@ -137,10 +139,37 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 获取沙盒内清单文件的路径
|
||||
/// </summary>
|
||||
public static string GetCacheManifestFilePath(string packageName)
|
||||
public static string GetCacheManifestFilePath(string packageName, string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestFileNameWithoutVersion(packageName);
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
|
||||
return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取沙盒内包裹的哈希文件的路径
|
||||
/// </summary>
|
||||
public static string GetCachePackageHashFilePath(string packageName, string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
|
||||
return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取沙盒内包裹的版本文件的路径
|
||||
/// </summary>
|
||||
public static string GetCachePackageVersionFilePath(string packageName)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
|
||||
return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存默认的包裹版本
|
||||
/// </summary>
|
||||
public static void SaveCachePackageVersionFile(string packageName, string version)
|
||||
{
|
||||
string filePath = GetCachePackageVersionFilePath(packageName);
|
||||
FileUtility.CreateFile(filePath, version);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue