From cc04efe76b30c961cb3b00fb8d2dd38bfe7053d3 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 26 Oct 2022 21:02:25 +0800 Subject: [PATCH] Update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UpdateStaticVersionOperation.PackageCRC重名为PackageVersion。 AssetPackage.GetHumanReadableVersion()重名为GetPackageVersion() --- Assets/YooAsset/Runtime/AssetsPackage.cs | 28 ++--- .../Operations/InitializationOperation.cs | 32 +++--- .../Operations/UpdateManifestOperation.cs | 107 +++++++++++------- .../Operations/UpdatePackageOperation.cs | 8 +- .../UpdateStaticVersionOperation.cs | 16 +-- .../Runtime/PatchSystem/PatchManifest.cs | 4 +- .../PlayMode/EditorSimulateModeImpl.cs | 6 +- .../PatchSystem/PlayMode/HostPlayModeImpl.cs | 18 +-- .../PlayMode/OfflinePlayModeImpl.cs | 6 +- .../Runtime/Settings/YooAssetSettings.cs | 9 +- .../Runtime/Settings/YooAssetSettingsData.cs | 20 ++-- Assets/YooAsset/Runtime/YooAssetsExtension.cs | 6 +- 12 files changed, 143 insertions(+), 117 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetsPackage.cs b/Assets/YooAsset/Runtime/AssetsPackage.cs index a5f770b..c2a67af 100644 --- a/Assets/YooAsset/Runtime/AssetsPackage.cs +++ b/Assets/YooAsset/Runtime/AssetsPackage.cs @@ -212,9 +212,9 @@ namespace YooAsset /// /// 向网络端请求并更新补丁清单 /// - /// 更新的资源包裹版本 + /// 更新的包裹版本 /// 超时时间(默认值:60秒) - public UpdateManifestOperation UpdateManifestAsync(string packageCRC, int timeout = 60) + public UpdateManifestOperation UpdateManifestAsync(string packageVersion, int timeout = 60) { DebugCheckInitialize(); DebugCheckUpdateManifest(); @@ -232,7 +232,7 @@ namespace YooAsset } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageCRC, timeout); + return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageVersion, timeout); } else { @@ -244,8 +244,8 @@ namespace YooAsset /// 弱联网情况下加载补丁清单 /// 注意:当指定版本内容验证失败后会返回失败。 /// - /// 指定的资源包裹版本 - public UpdateManifestOperation WeaklyUpdateManifestAsync(string packageCRC) + /// 指定的包裹版本 + public UpdateManifestOperation WeaklyUpdateManifestAsync(string packageVersion) { DebugCheckInitialize(); if (_playMode == EPlayMode.EditorSimulateMode) @@ -262,7 +262,7 @@ namespace YooAsset } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.WeaklyUpdatePatchManifestAsync(PackageName, packageCRC); + return _hostPlayModeImpl.WeaklyUpdatePatchManifestAsync(PackageName, packageVersion); } else { @@ -271,22 +271,22 @@ namespace YooAsset } /// - /// 获取人类可读的版本信息 + /// 获取包裹的版本信息 /// - public string GetHumanReadableVersion() + public string GetPackageVersion() { DebugCheckInitialize(); if (_playMode == EPlayMode.EditorSimulateMode) { - return _editorSimulateModeImpl.GetHumanReadableVersion(); + return _editorSimulateModeImpl.GetPackageVersion(); } else if (_playMode == EPlayMode.OfflinePlayMode) { - return _offlinePlayModeImpl.GetHumanReadableVersion(); + return _offlinePlayModeImpl.GetPackageVersion(); } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.GetHumanReadableVersion(); + return _hostPlayModeImpl.GetPackageVersion(); } else { @@ -898,9 +898,9 @@ namespace YooAsset /// /// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件 /// - /// 指定更新的资源包裹版本 + /// 指定更新的包裹版本 /// 超时时间 - public UpdatePackageOperation UpdatePackageAsync(string packageCRC, int timeout = 60) + public UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60) { DebugCheckInitialize(); if (_playMode == EPlayMode.EditorSimulateMode) @@ -917,7 +917,7 @@ namespace YooAsset } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageCRC, timeout); + return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageVersion, timeout); } else { diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs index 4aaa1f7..2280893 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/InitializationOperation.cs @@ -173,10 +173,11 @@ namespace YooAsset Done, } - private string _buildinPackageName; + private readonly string _buildinPackageName; private ESteps _steps = ESteps.LoadStaticVersion; private UnityWebDataRequester _downloader1; private UnityWebDataRequester _downloader2; + private string _buildinPackageVersion; /// /// 错误日志 @@ -188,11 +189,6 @@ namespace YooAsset /// public PatchManifest Result { private set; get; } - /// - /// 内置补丁清单CRC - /// - public string BuildinPackageCRC { private set; get; } - public AppManifestLoader(string buildinPackageName) { @@ -227,7 +223,7 @@ namespace YooAsset if (_steps == ESteps.LoadStaticVersion) { - string fileName = YooAssetSettingsData.GetStaticVersionFileName(_buildinPackageName); + string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_buildinPackageName); string filePath = PathHelper.MakeStreamingLoadPath(fileName); string url = PathHelper.ConvertToWWWPath(filePath); _downloader1 = new UnityWebDataRequester(); @@ -248,15 +244,23 @@ namespace YooAsset } else { - BuildinPackageCRC = _downloader1.GetText(); - _steps = ESteps.LoadAppManifest; + _buildinPackageVersion = _downloader1.GetText(); + if (string.IsNullOrEmpty(_buildinPackageVersion)) + { + Error = $"Buildin package version is empty !"; + _steps = ESteps.Done; + } + else + { + _steps = ESteps.LoadAppManifest; + } } _downloader1.Dispose(); } if (_steps == ESteps.LoadAppManifest) { - string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, BuildinPackageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageVersion); string filePath = PathHelper.MakeStreamingLoadPath(fileName); string url = PathHelper.ConvertToWWWPath(filePath); _downloader2 = new UnityWebDataRequester(); @@ -299,7 +303,7 @@ namespace YooAsset } private string _buildinPackageName; - private string _buildinPackageCRC; + private string _buildinPackageVersion; private ESteps _steps = ESteps.CopyAppManifest; private UnityWebFileRequester _downloader1; @@ -314,10 +318,10 @@ namespace YooAsset public bool Result { private set; get; } - public AppManifestCopyer(string buildinPackageName, string buildinPackageCRC) + public AppManifestCopyer(string buildinPackageName, string buildinPackageVersion) { _buildinPackageName = buildinPackageName; - _buildinPackageCRC = buildinPackageCRC; + _buildinPackageVersion = buildinPackageVersion; } /// @@ -330,7 +334,7 @@ namespace YooAsset if (_steps == ESteps.CopyAppManifest) { - string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageVersion); string destFilePath = PathHelper.MakePersistentLoadPath(fileName); if (File.Exists(destFilePath)) { diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs index ff686ad..a01f042 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs @@ -52,7 +52,8 @@ namespace YooAsset private enum ESteps { None, - CheckManifestHash, + LoadWebHash, + CheckWebHash, LoadWebManifest, CheckWebManifest, InitVerifyingCache, @@ -63,18 +64,19 @@ namespace YooAsset private static int RequestCount = 0; private readonly HostPlayModeImpl _impl; private readonly string _packageName; - private readonly string _packageCRC; + private readonly string _packageVersion; private readonly int _timeout; - private UnityWebDataRequester _downloader; + private UnityWebDataRequester _downloader1; + private UnityWebDataRequester _downloader2; private CacheVerifier _cacheVerifier; private ESteps _steps = ESteps.None; private float _verifyTime; - internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout) + internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) { _impl = impl; _packageName = packageName; - _packageCRC = packageCRC; + _packageVersion = packageVersion; _timeout = timeout; #if UNITY_WEBGL @@ -86,59 +88,84 @@ namespace YooAsset internal override void Start() { RequestCount++; - _steps = ESteps.CheckManifestHash; + _steps = ESteps.LoadWebHash; } internal override void Update() { if (_steps == ESteps.None || _steps == ESteps.Done) return; - if (_steps == ESteps.CheckManifestHash) + if (_steps == ESteps.LoadWebHash) { - string cachedManifestCRC = GetSandboxPatchManifestFileHash(_packageName, _packageCRC); + 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.CheckWebHash; + } - // 如果补丁清单文件的哈希值相同 - if (cachedManifestCRC == _packageCRC) + if (_steps == ESteps.CheckWebHash) + { + if (_downloader1.IsDone() == false) + return; + + // Check error + if (_downloader1.HasError()) { - YooLogger.Log($"Patch manifest file hash is not change : {_packageCRC}"); - LoadSandboxPatchManifest(_packageName, _packageCRC); - FoundNewManifest = false; - _steps = ESteps.InitVerifyingCache; + _steps = ESteps.Done; + Status = EOperationStatus.Failed; + Error = _downloader1.GetError(); } else { - YooLogger.Log($"Patch manifest hash is change : {cachedManifestCRC} -> {_packageCRC}"); - FoundNewManifest = true; - _steps = ESteps.LoadWebManifest; + string webManifestHash = _downloader1.GetText(); + string cachedManifestHash = GetSandboxPatchManifestFileHash(_packageName, _packageVersion); + + // 如果补丁清单文件的哈希值相同 + if (cachedManifestHash == webManifestHash) + { + YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}"); + LoadSandboxPatchManifest(_packageName, _packageVersion); + FoundNewManifest = false; + _steps = ESteps.InitVerifyingCache; + } + else + { + YooLogger.Log($"Patch manifest hash is change : {cachedManifestHash} -> {webManifestHash}"); + FoundNewManifest = true; + _steps = ESteps.LoadWebManifest; + } } + _downloader1.Dispose(); } if (_steps == ESteps.LoadWebManifest) { - string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageVersion); string webURL = GetPatchManifestRequestURL(fileName); YooLogger.Log($"Beginning to request patch manifest : {webURL}"); - _downloader = new UnityWebDataRequester(); - _downloader.SendRequest(webURL, _timeout); + _downloader2 = new UnityWebDataRequester(); + _downloader2.SendRequest(webURL, _timeout); _steps = ESteps.CheckWebManifest; } if (_steps == ESteps.CheckWebManifest) { - if (_downloader.IsDone() == false) + if (_downloader2.IsDone() == false) return; // Check error - if (_downloader.HasError()) + if (_downloader2.HasError()) { _steps = ESteps.Done; Status = EOperationStatus.Failed; - Error = _downloader.GetError(); + Error = _downloader2.GetError(); } else { // 解析补丁清单 - if (ParseAndSaveRemotePatchManifest(_packageName, _packageCRC, _downloader.GetText())) + if (ParseAndSaveRemotePatchManifest(_packageName, _packageVersion, _downloader2.GetText())) { _steps = ESteps.InitVerifyingCache; } @@ -146,10 +173,10 @@ namespace YooAsset { _steps = ESteps.Done; Status = EOperationStatus.Failed; - Error = $"URL : {_downloader.URL} Error : remote patch manifest content is invalid"; + Error = $"URL : {_downloader2.URL} Error : remote patch manifest content is invalid"; } } - _downloader.Dispose(); + _downloader2.Dispose(); } if (_steps == ESteps.InitVerifyingCache) @@ -188,7 +215,7 @@ namespace YooAsset /// /// 解析并保存远端请求的补丁清单 /// - private bool ParseAndSaveRemotePatchManifest(string packageName, string packageCRC, string content) + private bool ParseAndSaveRemotePatchManifest(string packageName, string packageVersion, string content) { try { @@ -196,7 +223,7 @@ namespace YooAsset _impl.SetLocalPatchManifest(remotePatchManifest); YooLogger.Log("Save remote patch manifest file."); - string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion); string savePath = PathHelper.MakePersistentLoadPath(fileName); PatchManifest.Serialize(savePath, remotePatchManifest); return true; @@ -212,10 +239,10 @@ namespace YooAsset /// 加载沙盒内的补丁清单 /// 注意:在加载本地补丁清单之前,已经验证过文件的哈希值 /// - private void LoadSandboxPatchManifest(string packageName, string packageCRC) + private void LoadSandboxPatchManifest(string packageName, string packageVersion) { YooLogger.Log("Load sandbox patch manifest file."); - string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion); string filePath = PathHelper.MakePersistentLoadPath(fileName); string jsonData = File.ReadAllText(filePath); var sandboxPatchManifest = PatchManifest.Deserialize(jsonData); @@ -226,12 +253,12 @@ namespace YooAsset /// 获取沙盒内补丁清单文件的哈希值 /// 注意:如果沙盒内补丁清单文件不存在,返回空字符串 /// - private string GetSandboxPatchManifestFileHash(string packageName, string packageCRC) + private string GetSandboxPatchManifestFileHash(string packageName, string packageVersion) { - string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion); string filePath = PathHelper.MakePersistentLoadPath(fileName); if (File.Exists(filePath)) - return HashUtility.FileCRC32(filePath); + return HashUtility.FileMD5(filePath); else return string.Empty; } @@ -253,16 +280,16 @@ namespace YooAsset private readonly HostPlayModeImpl _impl; private readonly string _packageName; - private readonly string _packageCRC; + private readonly string _packageVersion; private ESteps _steps = ESteps.None; private CacheVerifier _cacheVerifier; private float _verifyTime; - internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC) + internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion) { _impl = impl; _packageName = packageName; - _packageCRC = packageCRC; + _packageVersion = packageVersion; #if UNITY_WEBGL _cacheVerifier = new CacheVerifierWithoutThread(); @@ -281,7 +308,7 @@ namespace YooAsset if (_steps == ESteps.LoadSandboxManifestHash) { - LoadSandboxPatchManifest(_packageName, _packageCRC); + LoadSandboxPatchManifest(_packageName, _packageVersion); _steps = ESteps.InitVerifyingCache; } @@ -321,7 +348,7 @@ namespace YooAsset { _steps = ESteps.Done; Status = EOperationStatus.Failed; - Error = $"The package resource {_packageName}_{_packageCRC} content has verify failed file !"; + Error = $"The package resource {_packageName}_{_packageVersion} content has verify failed file !"; } } } @@ -331,9 +358,9 @@ namespace YooAsset /// 加载沙盒内的补丁清单 /// 注意:在加载本地补丁清单之前,未验证过文件的哈希值 /// - private void LoadSandboxPatchManifest(string packageName, string packageCRC) + private void LoadSandboxPatchManifest(string packageName, string packageVersion) { - string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion); string filePath = PathHelper.MakePersistentLoadPath(fileName); if (File.Exists(filePath)) { diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs index 53f061e..e697f51 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs @@ -80,17 +80,17 @@ namespace YooAsset private static int RequestCount = 0; private readonly HostPlayModeImpl _impl; private readonly string _packageName; - private readonly string _packageCRC; + private readonly string _packageVersion; private readonly int _timeout; private ESteps _steps = ESteps.None; private UnityWebDataRequester _downloader; private PatchManifest _remotePatchManifest; - internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout) + internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) { _impl = impl; _packageName = packageName; - _packageCRC = packageCRC; + _packageVersion = packageVersion; _timeout = timeout; } internal override void Start() @@ -105,7 +105,7 @@ namespace YooAsset if (_steps == ESteps.LoadWebManifest) { - string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageCRC); + string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageVersion); string webURL = GetPatchManifestRequestURL(fileName); YooLogger.Log($"Beginning to request patch manifest : {webURL}"); _downloader = new UnityWebDataRequester(); diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs index 3d6e7c1..0d79803 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using UnityEngine; namespace YooAsset { @@ -9,9 +10,9 @@ namespace YooAsset public abstract class UpdateStaticVersionOperation : AsyncOperationBase { /// - /// 包裹文件的哈希值 + /// 当前最新的包裹版本 /// - public string PackageCRC { protected set; get; } = string.Empty; + public string PackageVersion { protected set; get; } } /// @@ -80,8 +81,8 @@ namespace YooAsset if (_steps == ESteps.LoadStaticVersion) { - string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(_packageName); - string webURL = GetStaticVersionRequestURL(versionFileName); + string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName); + string webURL = GetStaticVersionRequestURL(fileName); YooLogger.Log($"Beginning to request static version : {webURL}"); _downloader = new UnityWebDataRequester(); _downloader.SendRequest(webURL, _timeout); @@ -102,16 +103,15 @@ namespace YooAsset } else { - string packageCRC = _downloader.GetText(); - if(string.IsNullOrEmpty(packageCRC)) + PackageVersion = _downloader.GetText(); + if (string.IsNullOrEmpty(PackageVersion)) { _steps = ESteps.Done; Status = EOperationStatus.Failed; - Error = $"URL : {_downloader.URL} Error : static version content is empty."; + Error = $"Static package version is empty : {_downloader.URL}"; } else { - PackageCRC = packageCRC; _steps = ESteps.Done; Status = EOperationStatus.Succeed; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs index 36766dc..3cad644 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs @@ -33,9 +33,9 @@ namespace YooAsset public string PackageName; /// - /// 人类可读的版本信息 + /// 资源包裹的版本信息 /// - public string HumanReadableVersion; + public string PackageVersion; /// /// 资源列表(主动收集的资源列表) diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs index ef92f65..9f7ece5 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs @@ -21,13 +21,13 @@ namespace YooAsset } /// - /// 获取人类可读的版本信息 + /// 获取包裹的版本信息 /// - public string GetHumanReadableVersion() + public string GetPackageVersion() { if (_simulatePatchManifest == null) return string.Empty; - return _simulatePatchManifest.HumanReadableVersion; + return _simulatePatchManifest.PackageVersion; } internal void SetSimulatePatchManifest(PatchManifest patchManifest) diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index 82ca124..07e61e8 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -32,13 +32,13 @@ namespace YooAsset } /// - /// 获取人类可读的版本信息 + /// 获取包裹的版本信息 /// - public string GetHumanReadableVersion() + public string GetPackageVersion() { if (LocalPatchManifest == null) return string.Empty; - return LocalPatchManifest.HumanReadableVersion; + return LocalPatchManifest.PackageVersion; } /// @@ -54,9 +54,9 @@ namespace YooAsset /// /// 异步更新补丁清单 /// - public UpdateManifestOperation UpdatePatchManifestAsync(string packageName, string packageCRC, int timeout) + public UpdateManifestOperation UpdatePatchManifestAsync(string packageName, string packageVersion, int timeout) { - var operation = new HostPlayModeUpdateManifestOperation(this, packageName, packageCRC, timeout); + var operation = new HostPlayModeUpdateManifestOperation(this, packageName, packageVersion, timeout); OperationSystem.StartOperation(operation); return operation; } @@ -64,9 +64,9 @@ namespace YooAsset /// /// 异步更新补丁清单(弱联网) /// - public UpdateManifestOperation WeaklyUpdatePatchManifestAsync(string packageName, string packageCRC) + public UpdateManifestOperation WeaklyUpdatePatchManifestAsync(string packageName, string packageVersion) { - var operation = new HostPlayModeWeaklyUpdateManifestOperation(this, packageName, packageCRC); + var operation = new HostPlayModeWeaklyUpdateManifestOperation(this, packageName, packageVersion); OperationSystem.StartOperation(operation); return operation; } @@ -74,9 +74,9 @@ namespace YooAsset /// /// 异步更新资源包裹 /// - public UpdatePackageOperation UpdatePackageAsync(string packageName, string packageCRC, int timeout) + public UpdatePackageOperation UpdatePackageAsync(string packageName, string packageVersion, int timeout) { - var operation = new HostPlayModeUpdatePackageOperation(this, packageName, packageCRC, timeout); + var operation = new HostPlayModeUpdatePackageOperation(this, packageName, packageVersion, timeout); OperationSystem.StartOperation(operation); return operation; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs index 2217fd2..447b360 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs @@ -22,13 +22,13 @@ namespace YooAsset } /// - /// 获取人类可读的版本信息 + /// 获取包裹的版本信息 /// - public string GetHumanReadableVersion() + public string GetPackageVersion() { if (_appPatchManifest == null) return string.Empty; - return _appPatchManifest.HumanReadableVersion; + return _appPatchManifest.PackageVersion; } internal List GetVerifyInfoList() diff --git a/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs index 489f188..903709b 100644 --- a/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs +++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs @@ -22,9 +22,9 @@ namespace YooAsset /// - /// 补丁清单文件版本 + /// 补丁清单文件格式版本 /// - public const string PatchManifestFileVersion = "1.3.0"; + public const string PatchManifestFileVersion = "1.3.3"; /// /// 构建输出文件夹名称 @@ -36,11 +36,6 @@ namespace YooAsset /// public const string ReportFileName = "BuildReport"; - /// - /// 静态版本文件 - /// - public const string VersionFileName = "StaticVersion"; - /// /// Unity着色器资源包名称 /// diff --git a/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs index da5403a..0eaf861 100644 --- a/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs +++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs @@ -35,33 +35,33 @@ namespace YooAsset /// /// 获取构建报告文件名 /// - public static string GetReportFileName(string packageName, string packageCRC) + public static string GetReportFileName(string packageName, string packageVersion) { - return $"{YooAssetSettings.ReportFileName}_{packageName}_{packageCRC}.json"; + return $"{YooAssetSettings.ReportFileName}_{packageName}_{packageVersion}.json"; } /// /// 获取补丁清单文件完整名称 /// - public static string GetPatchManifestFileName(string packageName, string packageCRC) + public static string GetPatchManifestFileName(string packageName, string packageVersion) { - return $"{Setting.PatchManifestFileName}_{packageName}_{packageCRC}.bytes"; + return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.bytes"; } /// - /// 获取补丁清单文件临时名称 + /// 获取补丁清单哈希文件完整名称 /// - public static string GetPatchManifestTempFileName(string packageName) + public static string GetPatchManifestHashFileName(string packageName, string packageVersion) { - return $"{Setting.PatchManifestFileName}_{packageName}.temp"; + return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.hash"; } /// - /// 获取静态版本文件名称 + /// 获取补丁清单版本文件完整名称 /// - public static string GetStaticVersionFileName(string packageName) + public static string GetPatchManifestVersionFileName(string packageName) { - return $"{YooAssetSettings.VersionFileName}_{packageName}.bytes"; + return $"{Setting.PatchManifestFileName}_{packageName}.version"; } /// diff --git a/Assets/YooAsset/Runtime/YooAssetsExtension.cs b/Assets/YooAsset/Runtime/YooAssetsExtension.cs index 43ce4d9..2d26021 100644 --- a/Assets/YooAsset/Runtime/YooAssetsExtension.cs +++ b/Assets/YooAsset/Runtime/YooAssetsExtension.cs @@ -369,12 +369,12 @@ namespace YooAsset /// /// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件 /// - /// 指定更新的资源包裹版本 + /// 指定更新的包裹版本 /// 超时时间 - public static UpdatePackageOperation UpdatePackageAsync(string packageCRC, int timeout = 60) + public static UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60) { DebugCheckDefaultPackageValid(); - return _defaultPackage.UpdatePackageAsync(packageCRC, timeout); + return _defaultPackage.UpdatePackageAsync(packageVersion, timeout); } #endregion