From 812c46adebdec5ec99baeeb3cff9a9ee7ce93fb7 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sat, 6 May 2023 10:42:33 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 销毁Package的时候清空缓存记录。 --- Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs | 11 ++++++++++- Assets/YooAsset/Runtime/YooAssets.cs | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs index 94310ae..e4f7848 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -23,6 +23,15 @@ namespace YooAsset _cachedDic.Clear(); } + /// + /// 清空指定包裹的所有缓存数据 + /// + public static void ClearPackage(string packageName) + { + var cache = GetOrCreateCache(packageName); + cache.ClearAll(); + } + /// /// 获取缓存文件总数 /// @@ -115,7 +124,7 @@ namespace YooAsset { return VerifyingInternal(element.TempDataFilePath, element.FileSize, element.FileCRC, EVerifyLevel.High); } - + /// /// 验证记录文件(主线程内操作) /// diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index b75a9c5..cf93c23 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -150,6 +150,9 @@ namespace YooAsset YooLogger.Log($"Destroy resource package : {packageName}"); _packages.Remove(package); package.DestroyPackage(); + + // 清空缓存 + CacheSystem.ClearPackage(packageName); } ///