update runtime code

UpdatePackageManifestAsync方法增加自动保存版本号参数
pull/102/head
hevinci 2023-04-22 17:20:23 +08:00
parent aaab6692c3
commit 1b75f4b6e9
6 changed files with 15 additions and 9 deletions

View File

@ -69,6 +69,7 @@ namespace YooAsset
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 _autoSaveVersion;
private readonly int _timeout; private readonly int _timeout;
private LoadCacheManifestOperation _tryLoadCacheManifestOp; private LoadCacheManifestOperation _tryLoadCacheManifestOp;
private LoadCacheManifestOperation _loadCacheManifestOp; private LoadCacheManifestOperation _loadCacheManifestOp;
@ -76,11 +77,12 @@ namespace YooAsset
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveVersion, int timeout)
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_packageVersion = packageVersion; _packageVersion = packageVersion;
_autoSaveVersion = autoSaveVersion;
_timeout = timeout; _timeout = timeout;
} }
internal override void Start() internal override void Start()
@ -120,6 +122,8 @@ namespace YooAsset
if (_tryLoadCacheManifestOp.Status == EOperationStatus.Succeed) if (_tryLoadCacheManifestOp.Status == EOperationStatus.Succeed)
{ {
_impl.ActiveManifest = _tryLoadCacheManifestOp.Manifest; _impl.ActiveManifest = _tryLoadCacheManifestOp.Manifest;
if (_autoSaveVersion)
SavePackageVersion();
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
} }
@ -166,6 +170,8 @@ namespace YooAsset
if (_loadCacheManifestOp.Status == EOperationStatus.Succeed) if (_loadCacheManifestOp.Status == EOperationStatus.Succeed)
{ {
_impl.ActiveManifest = _loadCacheManifestOp.Manifest; _impl.ActiveManifest = _loadCacheManifestOp.Manifest;
if (_autoSaveVersion)
SavePackageVersion();
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
} }

View File

@ -43,7 +43,7 @@ namespace YooAsset
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout) UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout)
{ {
var operation = new EditorPlayModeUpdatePackageManifestOperation(); var operation = new EditorPlayModeUpdatePackageManifestOperation();
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);

View File

@ -111,9 +111,9 @@ namespace YooAsset
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout) UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout)
{ {
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, timeout); var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, autoSaveVersion, timeout);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }

View File

@ -43,7 +43,7 @@ namespace YooAsset
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout) UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout)
{ {
var operation = new OfflinePlayModeUpdatePackageManifestOperation(); var operation = new OfflinePlayModeUpdatePackageManifestOperation();
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);

View File

@ -220,13 +220,13 @@ namespace YooAsset
/// 向网络端请求并更新清单 /// 向网络端请求并更新清单
/// </summary> /// </summary>
/// <param name="packageVersion">更新的包裹版本</param> /// <param name="packageVersion">更新的包裹版本</param>
/// <param name="autoActiveManifest">自动激活清单</param> /// <param name="autoSaveVersion">更新成功后自动保存版本号,作为下次初始化的版本。</param>
/// <param name="timeout">超时时间默认值60秒</param> /// <param name="timeout">超时时间默认值60秒</param>
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60) public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
DebugCheckUpdateManifest(); DebugCheckUpdateManifest();
return _playModeServices.UpdatePackageManifestAsync(packageVersion, timeout); return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
} }
/// <summary> /// <summary>

View File

@ -21,7 +21,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 向网络端请求并更新清单 /// 向网络端请求并更新清单
/// </summary> /// </summary>
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout); UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout);
/// <summary> /// <summary>
/// 预下载指定版本的包裹内容 /// 预下载指定版本的包裹内容