From 3cfc084e62b66b0aff59f31238b689695e5415ce Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 28 Feb 2023 19:17:05 +0800 Subject: [PATCH] update cache system --- .../Operations/PackageCachingOperation.cs | 2 -- Assets/YooAsset/Runtime/Utility/YooHelper.cs | 20 +++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageCachingOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageCachingOperation.cs index ae87610..8f9f55a 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageCachingOperation.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageCachingOperation.cs @@ -39,7 +39,6 @@ namespace YooAsset { _findCacheFilesOp = new FindCacheFilesOperation(_packageName); OperationSystem.StartOperation(_findCacheFilesOp); - _steps = ESteps.VerifyCacheFiles; } Progress = _findCacheFilesOp.Progress; @@ -55,7 +54,6 @@ namespace YooAsset { _verifyCacheFilesOp = VerifyCacheFilesOperation.CreateOperation(_findCacheFilesOp.VerifyElements); OperationSystem.StartOperation(_verifyCacheFilesOp); - _steps = ESteps.VerifyCacheFiles; } Progress = _verifyCacheFilesOp.Progress; diff --git a/Assets/YooAsset/Runtime/Utility/YooHelper.cs b/Assets/YooAsset/Runtime/Utility/YooHelper.cs index 83131a5..25a03d2 100644 --- a/Assets/YooAsset/Runtime/Utility/YooHelper.cs +++ b/Assets/YooAsset/Runtime/Utility/YooHelper.cs @@ -124,19 +124,31 @@ namespace YooAsset /// /// 获取缓存的BundleFile文件夹路径 /// + private readonly static Dictionary _cachedBundleFileFolder = new Dictionary(100); public static string GetCachedBundleFileFolderPath(string packageName) { - string root = PathHelper.MakePersistentLoadPath(CacheFolderName); - return $"{root}/{packageName}/{CachedBundleFileFolder}"; + if (_cachedBundleFileFolder.TryGetValue(packageName, out string value) == false) + { + string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + value = $"{root}/{packageName}/{CachedBundleFileFolder}"; + _cachedBundleFileFolder.Add(packageName, value); + } + return value; } /// /// 获取缓存的RawFile文件夹路径 /// + private readonly static Dictionary _cachedRawFileFolder = new Dictionary(100); public static string GetCachedRawFileFolderPath(string packageName) { - string root = PathHelper.MakePersistentLoadPath(CacheFolderName); - return $"{root}/{packageName}/{CachedRawFileFolder}"; + if (_cachedRawFileFolder.TryGetValue(packageName, out string value) == false) + { + string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + value = $"{root}/{packageName}/{CachedRawFileFolder}"; + _cachedRawFileFolder.Add(packageName, value); + } + return value; } ///