From a1ad7acb3d81a909d5c71262242b4bf3fd677088 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sat, 6 Aug 2022 16:23:38 +0800 Subject: [PATCH] Update CacheSystem --- .../Loader/AssetBundleFileLoader.cs | 2 +- .../Operations/RawFileOperation.cs | 16 +-- Assets/YooAsset/Runtime/CacheSystem.meta | 8 ++ .../Runtime/CacheSystem/CacheSystem.cs | 133 ++++++++++++++++++ .../Runtime/CacheSystem/CacheSystem.cs.meta | 11 ++ .../EVerifyLevel.cs | 0 .../EVerifyLevel.cs.meta | 0 .../PatchCacheVerifier.cs | 12 +- .../PatchCacheVerifier.cs.meta | 0 .../Runtime/DownloadSystem/DownloadSystem.cs | 87 +----------- .../Downloader/FileDownloader.cs | 4 +- .../Downloader/HttpDownloader.cs | 4 +- .../Runtime/PatchSystem/BundleInfo.cs | 38 ++--- .../Operations/UpdatePackageOperation.cs | 2 +- .../PatchSystem/PlayMode/HostPlayModeImpl.cs | 12 +- Assets/YooAsset/Runtime/YooAssets.cs | 4 +- 16 files changed, 202 insertions(+), 131 deletions(-) create mode 100644 Assets/YooAsset/Runtime/CacheSystem.meta create mode 100644 Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs create mode 100644 Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs.meta rename Assets/YooAsset/Runtime/{DownloadSystem => CacheSystem}/EVerifyLevel.cs (100%) rename Assets/YooAsset/Runtime/{DownloadSystem => CacheSystem}/EVerifyLevel.cs.meta (100%) rename Assets/YooAsset/Runtime/{DownloadSystem => CacheSystem}/PatchCacheVerifier.cs (93%) rename Assets/YooAsset/Runtime/{DownloadSystem => CacheSystem}/PatchCacheVerifier.cs.meta (100%) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs index 6b73c77..c6aefb1 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs @@ -169,7 +169,7 @@ namespace YooAsset if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache) { string cacheLoadPath = MainBundleInfo.GetCacheLoadPath(); - if (DownloadSystem.CheckContentIntegrity(EVerifyLevel.High, cacheLoadPath, MainBundleInfo.FileSize, MainBundleInfo.FileCRC) == false) + if (CacheSystem.CheckContentIntegrity(EVerifyLevel.High, cacheLoadPath, MainBundleInfo.FileSize, MainBundleInfo.FileCRC) == false) { if (File.Exists(cacheLoadPath)) { diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs index dc4a51d..f46b427 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs @@ -203,7 +203,7 @@ namespace YooAsset } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) { - if (DownloadSystem.ContainsVerifyFile(_bundleInfo.FileHash)) + if (CacheSystem.ContainsVerifyFile(_bundleInfo.FileHash)) _steps = ESteps.CheckAndCopyFile; else _steps = ESteps.DownloadFromApk; @@ -238,9 +238,9 @@ namespace YooAsset } else { - if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) + if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) { - DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); _steps = ESteps.CheckAndCopyFile; } else @@ -267,7 +267,7 @@ namespace YooAsset // 如果原生文件已经存在,则验证其完整性 if (File.Exists(CopyPath)) { - bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.FileSize, _bundleInfo.FileCRC); + bool result = CacheSystem.CheckContentIntegrity(CopyPath, _bundleInfo.FileSize, _bundleInfo.FileCRC); if (result) { _steps = ESteps.Done; @@ -355,7 +355,7 @@ namespace YooAsset } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) { - if (DownloadSystem.ContainsVerifyFile(_bundleInfo.FileHash)) + if (CacheSystem.ContainsVerifyFile(_bundleInfo.FileHash)) _steps = ESteps.CheckAndCopyFile; else _steps = ESteps.DownloadFromApk; @@ -421,9 +421,9 @@ namespace YooAsset } else { - if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) + if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) { - DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); _steps = ESteps.CheckAndCopyFile; } else @@ -450,7 +450,7 @@ namespace YooAsset // 如果原生文件已经存在,则验证其完整性 if (File.Exists(CopyPath)) { - bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.FileSize, _bundleInfo.FileCRC); + bool result = CacheSystem.CheckContentIntegrity(CopyPath, _bundleInfo.FileSize, _bundleInfo.FileCRC); if (result) { _steps = ESteps.Done; diff --git a/Assets/YooAsset/Runtime/CacheSystem.meta b/Assets/YooAsset/Runtime/CacheSystem.meta new file mode 100644 index 0000000..8a548d3 --- /dev/null +++ b/Assets/YooAsset/Runtime/CacheSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96a75a20111d6124696665e7aac3564c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs new file mode 100644 index 0000000..904b1c7 --- /dev/null +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -0,0 +1,133 @@ +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; + +namespace YooAsset +{ + internal static class CacheSystem + { + private readonly static HashSet _cacheBundles = new HashSet(); + private readonly static Dictionary _cachedHashList = new Dictionary(1000); + private static EVerifyLevel _verifyLevel = EVerifyLevel.High; + + public static void Initialize(EVerifyLevel verifyLevel) + { + _verifyLevel = verifyLevel; + } + + public static void DestroyAll() + { + _cacheBundles.Clear(); + } + + public static void WriteInfoFileForCachedFile() + { + + } + public static void ReadInfoFileForCachedFile() + { + + } + + public static void GetCachingDiskSpaceUsed() + { + + } + public static void GetCachingDiskSpaceFree() + { + + } + + public static bool IsCached(PatchBundle patchBundle) + { + return false; + } + public static void ClearCache() + { + + } + + + + + /// + /// 查询是否为验证文件 + /// 注意:被收录的文件完整性是绝对有效的 + /// + public static bool ContainsVerifyFile(string fileHash) + { + if (_cachedHashList.ContainsKey(fileHash)) + { + string fileName = _cachedHashList[fileHash]; + string filePath = SandboxHelper.MakeCacheFilePath(fileName); + if (File.Exists(filePath)) + { + return true; + } + else + { + _cachedHashList.Remove(fileHash); + YooLogger.Error($"Cache file is missing : {fileName}"); + return false; + } + } + else + { + return false; + } + } + + /// + /// 缓存验证过的文件 + /// + public static void CacheVerifyFile(string fileHash, string fileName) + { + if (_cachedHashList.ContainsKey(fileHash) == false) + { + YooLogger.Log($"Cache verify file : {fileName}"); + _cachedHashList.Add(fileHash, fileName); + } + } + + /// + /// 验证文件完整性 + /// + public static bool CheckContentIntegrity(string filePath, long fileSize, string fileCRC) + { + return CheckContentIntegrity(_verifyLevel, filePath, fileSize, fileCRC); + } + + /// + /// 验证文件完整性 + /// + public static bool CheckContentIntegrity(EVerifyLevel verifyLevel, string filePath, long fileSize, string fileCRC) + { + try + { + if (File.Exists(filePath) == false) + return false; + + // 先验证文件大小 + long size = FileUtility.GetFileSize(filePath); + if (size != fileSize) + return false; + + // 再验证文件CRC + if (verifyLevel == EVerifyLevel.High) + { + string crc = HashUtility.FileCRC32(filePath); + return crc == fileCRC; + } + else + { + return true; + } + } + catch (Exception) + { + return false; + } + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs.meta b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs.meta new file mode 100644 index 0000000..5fbd5e6 --- /dev/null +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8616c7550a7890141af598898a12df1b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/DownloadSystem/EVerifyLevel.cs b/Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs similarity index 100% rename from Assets/YooAsset/Runtime/DownloadSystem/EVerifyLevel.cs rename to Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs diff --git a/Assets/YooAsset/Runtime/DownloadSystem/EVerifyLevel.cs.meta b/Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/DownloadSystem/EVerifyLevel.cs.meta rename to Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs.meta diff --git a/Assets/YooAsset/Runtime/DownloadSystem/PatchCacheVerifier.cs b/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs similarity index 93% rename from Assets/YooAsset/Runtime/DownloadSystem/PatchCacheVerifier.cs rename to Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs index 2a50218..68ef2f5 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/PatchCacheVerifier.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs @@ -48,7 +48,7 @@ namespace YooAsset foreach (var patchBundle in localPatchManifest.BundleList) { // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 忽略APP资源 @@ -131,7 +131,7 @@ namespace YooAsset private void VerifyInThread(object infoObj) { ThreadInfo info = (ThreadInfo)infoObj; - info.Result = DownloadSystem.CheckContentIntegrity(info.FilePath, info.Bundle.FileSize, info.Bundle.FileCRC); + info.Result = CacheSystem.CheckContentIntegrity(info.FilePath, info.Bundle.FileSize, info.Bundle.FileCRC); _syncContext.Post(VerifyCallback, info); } private void VerifyCallback(object obj) @@ -140,7 +140,7 @@ namespace YooAsset if (info.Result) { VerifySuccessCount++; - DownloadSystem.CacheVerifyFile(info.Bundle.FileHash, info.Bundle.FileName); + CacheSystem.CacheVerifyFile(info.Bundle.FileHash, info.Bundle.FileName); } else { @@ -173,7 +173,7 @@ namespace YooAsset foreach (var patchBundle in localPatchManifest.BundleList) { // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 忽略APP资源 @@ -235,11 +235,11 @@ namespace YooAsset private void VerifyFile(PatchBundle patchBundle) { string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.FileName); - bool result = DownloadSystem.CheckContentIntegrity(filePath, patchBundle.FileSize, patchBundle.FileCRC); + bool result = CacheSystem.CheckContentIntegrity(filePath, patchBundle.FileSize, patchBundle.FileCRC); if (result) { VerifySuccessCount++; - DownloadSystem.CacheVerifyFile(patchBundle.FileHash, patchBundle.FileName); + CacheSystem.CacheVerifyFile(patchBundle.FileHash, patchBundle.FileName); } else { diff --git a/Assets/YooAsset/Runtime/DownloadSystem/PatchCacheVerifier.cs.meta b/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/DownloadSystem/PatchCacheVerifier.cs.meta rename to Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs.meta diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs index ebcb067..142413c 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs @@ -14,18 +14,15 @@ namespace YooAsset { private static readonly Dictionary _downloaderDic = new Dictionary(); private static readonly List _removeList = new List(100); - private static readonly Dictionary _cachedHashList = new Dictionary(1000); private static int _breakpointResumeFileSize = int.MaxValue; - private static EVerifyLevel _verifyLevel = EVerifyLevel.High; /// /// 初始化 /// - public static void Initialize(int breakpointResumeFileSize, EVerifyLevel verifyLevel) + public static void Initialize(int breakpointResumeFileSize) { _breakpointResumeFileSize = breakpointResumeFileSize; - _verifyLevel = verifyLevel; } /// @@ -62,7 +59,6 @@ namespace YooAsset } _downloaderDic.Clear(); _removeList.Clear(); - _cachedHashList.Clear(); _breakpointResumeFileSize = int.MaxValue; } @@ -80,7 +76,7 @@ namespace YooAsset } // 如果资源已经缓存 - if (ContainsVerifyFile(bundleInfo.FileHash)) + if (CacheSystem.ContainsVerifyFile(bundleInfo.FileHash)) { var tempDownloader = new TempDownloader(bundleInfo); return tempDownloader; @@ -108,84 +104,5 @@ namespace YooAsset { return _downloaderDic.Count; } - - /// - /// 查询是否为验证文件 - /// 注意:被收录的文件完整性是绝对有效的 - /// - public static bool ContainsVerifyFile(string fileHash) - { - if (_cachedHashList.ContainsKey(fileHash)) - { - string fileName = _cachedHashList[fileHash]; - string filePath = SandboxHelper.MakeCacheFilePath(fileName); - if (File.Exists(filePath)) - { - return true; - } - else - { - _cachedHashList.Remove(fileHash); - YooLogger.Error($"Cache file is missing : {fileName}"); - return false; - } - } - else - { - return false; - } - } - - /// - /// 缓存验证过的文件 - /// - public static void CacheVerifyFile(string fileHash, string fileName) - { - if (_cachedHashList.ContainsKey(fileHash) == false) - { - YooLogger.Log($"Cache verify file : {fileName}"); - _cachedHashList.Add(fileHash, fileName); - } - } - - /// - /// 验证文件完整性 - /// - public static bool CheckContentIntegrity(string filePath, long fileSize, string fileCRC) - { - return CheckContentIntegrity(_verifyLevel, filePath, fileSize, fileCRC); - } - - /// - /// 验证文件完整性 - /// - public static bool CheckContentIntegrity(EVerifyLevel verifyLevel, string filePath, long fileSize, string fileCRC) - { - try - { - if (File.Exists(filePath) == false) - return false; - - // 先验证文件大小 - long size = FileUtility.GetFileSize(filePath); - if (size != fileSize) - return false; - - // 再验证文件CRC - if (verifyLevel == EVerifyLevel.High) - { - string crc = HashUtility.FileCRC32(filePath); - return crc == fileCRC; - } - else - { - return true; - } - } - catch (Exception) - { - return false; - } - } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs index 731efb4..7def45d 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs @@ -81,7 +81,7 @@ namespace YooAsset if (hasError == false) { // 注意:如果文件验证失败需要删除文件 - if (DownloadSystem.CheckContentIntegrity(_bundleInfo.GetCacheLoadPath(), _bundleInfo.FileSize, _bundleInfo.FileCRC) == false) + if (CacheSystem.CheckContentIntegrity(_bundleInfo.GetCacheLoadPath(), _bundleInfo.FileSize, _bundleInfo.FileCRC) == false) { hasError = true; _lastError = $"Verification failed"; @@ -91,7 +91,7 @@ namespace YooAsset if (hasError == false) { _steps = ESteps.Succeed; - DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); } else { diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs index 0c2b9a1..59888e2 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs @@ -156,7 +156,7 @@ namespace YooAsset // 验证下载文件完整性 if (DownloadedBytes == (ulong)_fileSize) { - bool verfiyResult = DownloadSystem.CheckContentIntegrity(_savePath, _fileSize, _fileCRC); + bool verfiyResult = CacheSystem.CheckContentIntegrity(_savePath, _fileSize, _fileCRC); if (verfiyResult == false) { Error = $"Verify download content failed : {_fileName}"; @@ -226,7 +226,7 @@ namespace YooAsset } else { - DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); _steps = ESteps.Succeed; } } diff --git a/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs b/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs index f48dabb..b8bda18 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/BundleInfo.cs @@ -12,7 +12,7 @@ namespace YooAsset LoadFromEditor, } - private readonly PatchBundle _patchBundle; + public readonly PatchBundle LoadBundle; public readonly ELoadMode LoadMode; private string _streamingPath; @@ -50,10 +50,10 @@ namespace YooAsset { get { - if (_patchBundle == null) + if (LoadBundle == null) return string.Empty; else - return _patchBundle.FileHash; + return LoadBundle.FileHash; } } @@ -64,10 +64,10 @@ namespace YooAsset { get { - if (_patchBundle == null) + if (LoadBundle == null) return string.Empty; else - return _patchBundle.FileCRC; + return LoadBundle.FileCRC; } } @@ -78,10 +78,10 @@ namespace YooAsset { get { - if (_patchBundle == null) + if (LoadBundle == null) return 0; else - return _patchBundle.FileSize; + return LoadBundle.FileSize; } } @@ -92,10 +92,10 @@ namespace YooAsset { get { - if (_patchBundle == null) + if (LoadBundle == null) return false; else - return _patchBundle.IsEncrypted; + return LoadBundle.IsEncrypted; } } @@ -106,10 +106,10 @@ namespace YooAsset { get { - if (_patchBundle == null) + if (LoadBundle == null) return false; else - return _patchBundle.IsRawFile; + return LoadBundle.IsRawFile; } } @@ -120,7 +120,7 @@ namespace YooAsset { get { - return _patchBundle == null; + return LoadBundle == null; } } @@ -130,7 +130,7 @@ namespace YooAsset } public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string mainURL, string fallbackURL) { - _patchBundle = patchBundle; + LoadBundle = patchBundle; LoadMode = loadMode; BundleName = patchBundle.BundleName; FileName = patchBundle.FileName; @@ -140,7 +140,7 @@ namespace YooAsset } public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath) { - _patchBundle = patchBundle; + LoadBundle = patchBundle; LoadMode = loadMode; BundleName = patchBundle.BundleName; FileName = patchBundle.FileName; @@ -150,7 +150,7 @@ namespace YooAsset } public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode) { - _patchBundle = patchBundle; + LoadBundle = patchBundle; LoadMode = loadMode; BundleName = patchBundle.BundleName; FileName = patchBundle.FileName; @@ -164,11 +164,11 @@ namespace YooAsset /// public string GetStreamingLoadPath() { - if (_patchBundle == null) + if (LoadBundle == null) return string.Empty; if (string.IsNullOrEmpty(_streamingPath)) - _streamingPath = PathHelper.MakeStreamingLoadPath(_patchBundle.FileName); + _streamingPath = PathHelper.MakeStreamingLoadPath(LoadBundle.FileName); return _streamingPath; } @@ -177,11 +177,11 @@ namespace YooAsset /// public string GetCacheLoadPath() { - if (_patchBundle == null) + if (LoadBundle == null) return string.Empty; if (string.IsNullOrEmpty(_cachePath)) - _cachePath = SandboxHelper.MakeCacheFilePath(_patchBundle.FileName); + _cachePath = SandboxHelper.MakeCacheFilePath(LoadBundle.FileName); return _cachePath; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs index d3b3e25..e90ad90 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs @@ -198,7 +198,7 @@ namespace YooAsset foreach (var patchBundle in _remotePatchManifest.BundleList) { // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 忽略APP资源 diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index 04f56fc..1507d40 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -131,7 +131,7 @@ namespace YooAsset foreach (var patchBundle in LocalPatchManifest.BundleList) { // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 忽略APP资源 @@ -163,7 +163,7 @@ namespace YooAsset foreach (var patchBundle in LocalPatchManifest.BundleList) { // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 忽略APP资源 @@ -233,7 +233,7 @@ namespace YooAsset foreach (var patchBundle in checkList) { // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 忽略APP资源 @@ -269,7 +269,7 @@ namespace YooAsset continue; // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; // 查询DLC资源 @@ -301,7 +301,7 @@ namespace YooAsset continue; // 忽略缓存文件 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) continue; downloadList.Add(patchBundle); @@ -377,7 +377,7 @@ namespace YooAsset throw new Exception("Should never get here !"); // 查询沙盒资源 - if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) { BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache); return bundleInfo; diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 399fcf5..3e6d8ae 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -202,7 +202,8 @@ namespace YooAsset if (_playMode == EPlayMode.HostPlayMode) { var hostPlayModeParameters = parameters as HostPlayModeParameters; - DownloadSystem.Initialize(hostPlayModeParameters.BreakpointResumeFileSize, hostPlayModeParameters.VerifyLevel); + CacheSystem.Initialize(hostPlayModeParameters.VerifyLevel); + DownloadSystem.Initialize(hostPlayModeParameters.BreakpointResumeFileSize); } // 初始化资源系统 @@ -1029,6 +1030,7 @@ namespace YooAsset OperationSystem.DestroyAll(); DownloadSystem.DestroyAll(); + CacheSystem.DestroyAll(); AssetSystem.DestroyAll(); YooLogger.Log("YooAssets destroy all !"); }