From 1b75f4b6e9ec4e2f91fc42da2ece4c4ff3536a43 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sat, 22 Apr 2023 17:20:23 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UpdatePackageManifestAsync方法增加自动保存版本号参数 --- .../Operations/UpdatePackageManifestOperation.cs | 8 +++++++- .../PackageSystem/PlayMode/EditorSimulateModeImpl.cs | 2 +- .../Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs | 4 ++-- .../Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs | 2 +- Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs | 6 +++--- .../Runtime/Services/Internal/IPlayModeServices.cs | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/UpdatePackageManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/UpdatePackageManifestOperation.cs index b9d194d..795df7b 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/UpdatePackageManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/UpdatePackageManifestOperation.cs @@ -69,6 +69,7 @@ namespace YooAsset private readonly HostPlayModeImpl _impl; private readonly string _packageName; private readonly string _packageVersion; + private readonly bool _autoSaveVersion; private readonly int _timeout; private LoadCacheManifestOperation _tryLoadCacheManifestOp; private LoadCacheManifestOperation _loadCacheManifestOp; @@ -76,11 +77,12 @@ namespace YooAsset 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; _packageName = packageName; _packageVersion = packageVersion; + _autoSaveVersion = autoSaveVersion; _timeout = timeout; } internal override void Start() @@ -120,6 +122,8 @@ namespace YooAsset if (_tryLoadCacheManifestOp.Status == EOperationStatus.Succeed) { _impl.ActiveManifest = _tryLoadCacheManifestOp.Manifest; + if (_autoSaveVersion) + SavePackageVersion(); _steps = ESteps.Done; Status = EOperationStatus.Succeed; } @@ -166,6 +170,8 @@ namespace YooAsset if (_loadCacheManifestOp.Status == EOperationStatus.Succeed) { _impl.ActiveManifest = _loadCacheManifestOp.Manifest; + if (_autoSaveVersion) + SavePackageVersion(); _steps = ESteps.Done; Status = EOperationStatus.Succeed; } diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs index 6d73edb..1fe8f3a 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs @@ -43,7 +43,7 @@ namespace YooAsset OperationSystem.StartOperation(operation); return operation; } - UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout) + UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout) { var operation = new EditorPlayModeUpdatePackageManifestOperation(); OperationSystem.StartOperation(operation); diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs index 290c10f..fc79a6b 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs @@ -111,9 +111,9 @@ namespace YooAsset OperationSystem.StartOperation(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); return operation; } diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs index a99439d..20d09af 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs @@ -43,7 +43,7 @@ namespace YooAsset OperationSystem.StartOperation(operation); return operation; } - UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout) + UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout) { var operation = new OfflinePlayModeUpdatePackageManifestOperation(); OperationSystem.StartOperation(operation); diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs index 3fd3df1..4bbb5f8 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs @@ -220,13 +220,13 @@ namespace YooAsset /// 向网络端请求并更新清单 /// /// 更新的包裹版本 - /// 自动激活清单 + /// 更新成功后自动保存版本号,作为下次初始化的版本。 /// 超时时间(默认值:60秒) - public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60) + public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60) { DebugCheckInitialize(); DebugCheckUpdateManifest(); - return _playModeServices.UpdatePackageManifestAsync(packageVersion, timeout); + return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout); } /// diff --git a/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs b/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs index 834e0bc..d1be3a0 100644 --- a/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs +++ b/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs @@ -21,7 +21,7 @@ namespace YooAsset /// /// 向网络端请求并更新清单 /// - UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout); + UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout); /// /// 预下载指定版本的包裹内容