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