diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs index a626247..54785ba 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleWebLoader.cs @@ -163,7 +163,8 @@ namespace YooAsset // 5. 从WEB网站获取AssetBundle文件 if (_steps == ESteps.LoadWebFile) { - _webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_fileLoadPath, Hash128.Parse(MainBundleInfo.Bundle.FileHash)); + var hash = Hash128.Parse(MainBundleInfo.Bundle.FileHash); + _webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_fileLoadPath, hash); _webRequest.SendWebRequest(); _steps = ESteps.CheckLoadWebFile; } diff --git a/Assets/YooAsset/Runtime/AssetsPackage.cs b/Assets/YooAsset/Runtime/AssetsPackage.cs index c9ab51b..6fddd76 100644 --- a/Assets/YooAsset/Runtime/AssetsPackage.cs +++ b/Assets/YooAsset/Runtime/AssetsPackage.cs @@ -185,24 +185,24 @@ namespace YooAsset /// 向网络端请求最新的资源版本 /// /// 超时时间(默认值:60秒) - public UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60) + public UpdatePackageVersionOperation UpdatePackageVersionAsync(int timeout = 60) { DebugCheckInitialize(); if (_playMode == EPlayMode.EditorSimulateMode) { - var operation = new EditorPlayModeUpdateStaticVersionOperation(); + var operation = new EditorPlayModeUpdatePackageVersionOperation(); OperationSystem.StartOperation(operation); return operation; } else if (_playMode == EPlayMode.OfflinePlayMode) { - var operation = new OfflinePlayModeUpdateStaticVersionOperation(); + var operation = new OfflinePlayModeUpdatePackageVersionOperation(); OperationSystem.StartOperation(operation); return operation; } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.UpdateStaticVersionAsync(PackageName, timeout); + return _hostPlayModeImpl.UpdatePackageVersionAsync(PackageName, timeout); } else { @@ -215,25 +215,25 @@ namespace YooAsset /// /// 更新的包裹版本 /// 超时时间(默认值:60秒) - public UpdateManifestOperation UpdateManifestAsync(string packageVersion, int timeout = 60) + public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60) { DebugCheckInitialize(); DebugCheckUpdateManifest(); if (_playMode == EPlayMode.EditorSimulateMode) { - var operation = new EditorPlayModeUpdateManifestOperation(); + var operation = new EditorPlayModeUpdatePackageManifestOperation(); OperationSystem.StartOperation(operation); return operation; } else if (_playMode == EPlayMode.OfflinePlayMode) { - var operation = new OfflinePlayModeUpdateManifestOperation(); + var operation = new OfflinePlayModeUpdatePackageManifestOperation(); OperationSystem.StartOperation(operation); return operation; } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageVersion, timeout); + return _hostPlayModeImpl.UpdatePackageManifestAsync(PackageName, packageVersion, timeout); } else { @@ -270,7 +270,18 @@ namespace YooAsset } /// - /// 获取包裹的版本信息 + /// 清理本地包裹未使用的缓存文件 + /// + public ClearPackageUnusedCacheFilesOperation ClearPackageUnusedCacheFilesAsync() + { + DebugCheckInitialize(); + var operation = new ClearPackageUnusedCacheFilesOperation(this); + OperationSystem.StartOperation(operation); + return operation; + } + + /// + /// 获取本地包裹的版本信息 /// public string GetPackageVersion() { @@ -899,24 +910,24 @@ namespace YooAsset /// /// 指定更新的包裹版本 /// 超时时间 - public UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60) + public DownloadPackageOperation DownloadPackageAsync(string packageVersion, int timeout = 60) { DebugCheckInitialize(); if (_playMode == EPlayMode.EditorSimulateMode) { - var operation = new EditorPlayModeUpdatePackageOperation(); + var operation = new EditorPlayModeDownloadPackageOperation(); OperationSystem.StartOperation(operation); return operation; } else if (_playMode == EPlayMode.OfflinePlayMode) { - var operation = new OfflinePlayModeUpdatePackageOperation(); + var operation = new OfflinePlayModeDownloadPackageOperation(); OperationSystem.StartOperation(operation); return operation; } else if (_playMode == EPlayMode.HostPlayMode) { - return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageVersion, timeout); + return _hostPlayModeImpl.DownloadPackageAsync(PackageName, packageVersion, timeout); } else { diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs index 4549745..3ee5b92 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -2,7 +2,6 @@ using System.IO; using System.Collections; using System.Collections.Generic; -using UnityEngine; namespace YooAsset { @@ -30,8 +29,8 @@ namespace YooAsset /// public static bool IsCached(PatchBundle patchBundle) { - string fileHash = patchBundle.FileHash; - if (_cachedDic.ContainsKey(fileHash)) + string cacheKey = patchBundle.CacheKey; + if (_cachedDic.ContainsKey(cacheKey)) { string filePath = patchBundle.CachedFilePath; if (File.Exists(filePath)) @@ -40,7 +39,7 @@ namespace YooAsset } else { - _cachedDic.Remove(fileHash); + _cachedDic.Remove(cacheKey); YooLogger.Error($"Cache file is missing : {filePath}"); return false; } @@ -56,12 +55,12 @@ namespace YooAsset /// public static void CacheBundle(PatchBundle patchBundle) { - string fileHash = patchBundle.FileHash; - if (_cachedDic.ContainsKey(fileHash) == false) + string cacheKey = patchBundle.CacheKey; + if (_cachedDic.ContainsKey(cacheKey) == false) { string filePath = patchBundle.CachedFilePath; YooLogger.Log($"Cache verify file : {filePath}"); - _cachedDic.Add(fileHash, patchBundle); + _cachedDic.Add(cacheKey, patchBundle); } } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/ClearUnusedCacheFilesOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/ClearPackageUnusedCacheFilesOperation.cs similarity index 82% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/ClearUnusedCacheFilesOperation.cs rename to Assets/YooAsset/Runtime/PatchSystem/Operations/ClearPackageUnusedCacheFilesOperation.cs index 5c72672..0091afc 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/ClearUnusedCacheFilesOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/ClearPackageUnusedCacheFilesOperation.cs @@ -5,9 +5,9 @@ using System.IO; namespace YooAsset { /// - /// 清理未使用的缓存资源操作类 + /// 清理本地包裹未使用的缓存文件 /// - public sealed class ClearUnusedCacheFilesOperation : AsyncOperationBase + public sealed class ClearPackageUnusedCacheFilesOperation : AsyncOperationBase { private enum ESteps { @@ -17,14 +17,14 @@ namespace YooAsset Done, } - private readonly List _packages; + private readonly AssetsPackage _package; private ESteps _steps = ESteps.None; private List _unusedCacheFilePaths; private int _unusedFileTotalCount = 0; - internal ClearUnusedCacheFilesOperation(List packages) + internal ClearPackageUnusedCacheFilesOperation(AssetsPackage package) { - _packages = packages; + _package = package; } internal override void Start() { @@ -84,27 +84,19 @@ namespace YooAsset /// private List GetUnusedCacheFilePaths() { - string cacheFolderPath = PersistentHelper.GetCacheFolderPath(); + string cacheFolderPath = PersistentHelper.GetCacheFolderPath(_package.PackageName); if (Directory.Exists(cacheFolderPath) == false) return new List(); - // 获取所有缓存文件 DirectoryInfo directoryInfo = new DirectoryInfo(cacheFolderPath); FileInfo[] fileInfos = directoryInfo.GetFiles(); List result = new List(fileInfos.Length); foreach (FileInfo fileInfo in fileInfos) { - bool used = false; - foreach (var package in _packages) + if (_package.IsIncludeBundleFile(fileInfo.Name) == false) { - if (package.IsIncludeBundleFile(fileInfo.Name)) - { - used = true; - break; - } - } - if (used == false) result.Add(fileInfo.FullName); + } } return result; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/ClearUnusedCacheFilesOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/ClearPackageUnusedCacheFilesOperation.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/ClearUnusedCacheFilesOperation.cs.meta rename to Assets/YooAsset/Runtime/PatchSystem/Operations/ClearPackageUnusedCacheFilesOperation.cs.meta diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs similarity index 90% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs rename to Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs index 3f4d89b..41e2a56 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs @@ -5,7 +5,7 @@ using System.IO; namespace YooAsset { - public abstract class UpdatePackageOperation : AsyncOperationBase + public abstract class DownloadPackageOperation : AsyncOperationBase { /// /// 创建包裹下载器 @@ -19,7 +19,7 @@ namespace YooAsset /// /// 编辑器下模拟运行的更新资源包裹操作 /// - internal sealed class EditorPlayModeUpdatePackageOperation : UpdatePackageOperation + internal sealed class EditorPlayModeDownloadPackageOperation : DownloadPackageOperation { internal override void Start() { @@ -43,7 +43,7 @@ namespace YooAsset /// /// 离线模式的更新资源包裹操作 /// - internal sealed class OfflinePlayModeUpdatePackageOperation : UpdatePackageOperation + internal sealed class OfflinePlayModeDownloadPackageOperation : DownloadPackageOperation { internal override void Start() { @@ -67,7 +67,7 @@ namespace YooAsset /// /// 联机模式的更新资源包裹操作 /// - internal sealed class HostPlayModeUpdatePackageOperation : UpdatePackageOperation + internal sealed class HostPlayModeDownloadPackageOperation : DownloadPackageOperation { private enum ESteps { @@ -86,7 +86,7 @@ namespace YooAsset private UnityWebDataRequester _downloader; private PatchManifest _remotePatchManifest; - internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) + internal HostPlayModeDownloadPackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) { _impl = impl; _packageName = packageName; @@ -160,7 +160,7 @@ namespace YooAsset } else { - YooLogger.Error($"{nameof(UpdatePackageOperation)} status is failed !"); + YooLogger.Error($"{nameof(DownloadPackageOperation)} status is failed !"); var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain, timeout); return operation; } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs.meta rename to Assets/YooAsset/Runtime/PatchSystem/Operations/DownloadPackageOperation.cs.meta diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs similarity index 91% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs rename to Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs index 0f485fb..b93c243 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs @@ -6,9 +6,9 @@ using System.IO; namespace YooAsset { /// - /// 更新清单操作 + /// 向远端请求并更新补丁清单 /// - public abstract class UpdateManifestOperation : AsyncOperationBase + public abstract class UpdatePackageManifestOperation : AsyncOperationBase { /// /// 是否发现了新的补丁清单 @@ -19,7 +19,7 @@ namespace YooAsset /// /// 编辑器下模拟运行的更新清单操作 /// - internal sealed class EditorPlayModeUpdateManifestOperation : UpdateManifestOperation + internal sealed class EditorPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation { internal override void Start() { @@ -33,7 +33,7 @@ namespace YooAsset /// /// 离线模式的更新清单操作 /// - internal sealed class OfflinePlayModeUpdateManifestOperation : UpdateManifestOperation + internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation { internal override void Start() { @@ -48,7 +48,7 @@ namespace YooAsset /// 联机模式的更新清单操作 /// 注意:优先比对沙盒清单哈希值,如果有变化就更新远端清单文件,并保存到本地。 /// - internal sealed class HostPlayModeUpdateManifestOperation : UpdateManifestOperation + internal sealed class HostPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation { private enum ESteps { @@ -77,7 +77,7 @@ namespace YooAsset private ESteps _steps = ESteps.None; private float _verifyTime; - internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) + internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) { _impl = impl; _packageName = packageName; diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateManifestOperation.cs.meta rename to Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageManifestOperation.cs.meta diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs similarity index 79% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs rename to Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs index f86fc6a..56c0dd5 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs @@ -5,9 +5,9 @@ using UnityEngine; namespace YooAsset { /// - /// 获取包裹的最新版本 + /// 请求远端包裹的最新版本 /// - public abstract class UpdateStaticVersionOperation : AsyncOperationBase + public abstract class UpdatePackageVersionOperation : AsyncOperationBase { /// /// 当前最新的包裹版本 @@ -16,9 +16,9 @@ namespace YooAsset } /// - /// 编辑器下模拟运行的获取包裹的最新版本操作 + /// 编辑器下模拟模式的请求远端包裹的最新版本 /// - internal sealed class EditorPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation + internal sealed class EditorPlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation { internal override void Start() { @@ -30,9 +30,9 @@ namespace YooAsset } /// - /// 离线模式的获取包裹的最新版本操作 + /// 离线模式的请求远端包裹的最新版本 /// - internal sealed class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation + internal sealed class OfflinePlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation { internal override void Start() { @@ -44,9 +44,9 @@ namespace YooAsset } /// - /// 联机模式的获取包裹的最新版本操作 + /// 联机模式的请求远端包裹的最新版本 /// - internal sealed class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation + internal sealed class HostPlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation { private enum ESteps { @@ -63,7 +63,7 @@ namespace YooAsset private ESteps _steps = ESteps.None; private UnityWebDataRequester _downloader; - internal HostPlayModeUpdateStaticVersionOperation(HostPlayModeImpl impl, string packageName, int timeout) + internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, int timeout) { _impl = impl; _packageName = packageName; diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs.meta b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/PatchSystem/Operations/UpdateStaticVersionOperation.cs.meta rename to Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageVersionOperation.cs.meta diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs index 7db22c7..5a1db90 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs @@ -41,10 +41,11 @@ namespace YooAsset /// public string[] Tags; + /// - /// 文件名称 - /// - public string FileName { private set; get; } + /// 所属的包裹名称 + /// + private string _packageName; /// /// 缓存文件路径 @@ -57,7 +58,7 @@ namespace YooAsset if (string.IsNullOrEmpty(_cachedFilePath) == false) return _cachedFilePath; - string cacheRoot = PersistentHelper.GetCacheFolderPath(); + string cacheRoot = PersistentHelper.GetCacheFolderPath(_packageName); _cachedFilePath = $"{cacheRoot}/{FileName}"; return _cachedFilePath; } @@ -79,6 +80,34 @@ namespace YooAsset } } + /// + /// 文件名称 + /// + private string _fileName; + public string FileName + { + get + { + if (string.IsNullOrEmpty(_fileName)) + throw new Exception("Should never get here !"); + return _fileName; + } + } + + /// + /// 缓存查询Key + /// + private string _cacheKey; + public string CacheKey + { + get + { + if (string.IsNullOrEmpty(_cacheKey)) + throw new Exception("Should never get here !"); + return _cacheKey; + } + } + public PatchBundle(string bundleName, string fileHash, string fileCRC, long fileSize, bool isRawFile, byte loadMethod, string[] tags) { @@ -92,11 +121,13 @@ namespace YooAsset } /// - /// 解析文件名称 + /// 解析资源包 /// - public void ParseFileName(int nameStype) + public void ParseBundle(string packageName, int nameStype) { - FileName = PatchManifest.CreateBundleFileName(nameStype, BundleName, FileHash); + _packageName = packageName; + _cacheKey = $"{packageName}-{FileHash}"; + _fileName = PatchManifest.CreateBundleFileName(nameStype, BundleName, FileHash); } /// diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs index 5b32a8d..8f25b97 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs @@ -290,7 +290,7 @@ namespace YooAsset // BundleList foreach (var patchBundle in patchManifest.BundleList) { - patchBundle.ParseFileName(patchManifest.OutputNameStyle); + patchBundle.ParseBundle(patchManifest.PackageName, patchManifest.OutputNameStyle); patchManifest.BundleDic.Add(patchBundle.BundleName, patchBundle); } diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index dc6964f..7c10a97 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -44,9 +44,9 @@ namespace YooAsset /// /// 异步更新资源版本号 /// - public UpdateStaticVersionOperation UpdateStaticVersionAsync(string packageName, int timeout) + public UpdatePackageVersionOperation UpdatePackageVersionAsync(string packageName, int timeout) { - var operation = new HostPlayModeUpdateStaticVersionOperation(this, packageName, timeout); + var operation = new HostPlayModeUpdatePackageVersionOperation(this, packageName, timeout); OperationSystem.StartOperation(operation); return operation; } @@ -54,9 +54,9 @@ namespace YooAsset /// /// 异步更新补丁清单 /// - public UpdateManifestOperation UpdatePatchManifestAsync(string packageName, string packageVersion, int timeout) + public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageName, string packageVersion, int timeout) { - var operation = new HostPlayModeUpdateManifestOperation(this, packageName, packageVersion, timeout); + var operation = new HostPlayModeUpdatePackageManifestOperation(this, packageName, packageVersion, timeout); OperationSystem.StartOperation(operation); return operation; } @@ -74,9 +74,9 @@ namespace YooAsset /// /// 异步更新资源包裹 /// - public UpdatePackageOperation UpdatePackageAsync(string packageName, string packageVersion, int timeout) + public DownloadPackageOperation DownloadPackageAsync(string packageName, string packageVersion, int timeout) { - var operation = new HostPlayModeUpdatePackageOperation(this, packageName, packageVersion, timeout); + var operation = new HostPlayModeDownloadPackageOperation(this, packageName, packageVersion, timeout); OperationSystem.StartOperation(operation); return operation; } diff --git a/Assets/YooAsset/Runtime/Utility/YooHelper.cs b/Assets/YooAsset/Runtime/Utility/YooHelper.cs index 6a3ccda..dadc15e 100644 --- a/Assets/YooAsset/Runtime/Utility/YooHelper.cs +++ b/Assets/YooAsset/Runtime/Utility/YooHelper.cs @@ -97,17 +97,18 @@ namespace YooAsset /// public static void DeleteCacheFolder() { - string directoryPath = GetCacheFolderPath(); - if (Directory.Exists(directoryPath)) - Directory.Delete(directoryPath, true); + string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + if (Directory.Exists(root)) + Directory.Delete(root, true); } /// /// 获取缓存文件夹路径 /// - public static string GetCacheFolderPath() + public static string GetCacheFolderPath(string packageName) { - return PathHelper.MakePersistentLoadPath(CacheFolderName); + string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + return $"{root}/{packageName}"; } #region 沙盒内清单相关 diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 88bb81d..6c9c200 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -193,16 +193,6 @@ namespace YooAsset #endregion #region 沙盒相关 - /// - /// 清理未使用的缓存文件 - /// - public static ClearUnusedCacheFilesOperation ClearUnusedCacheFiles() - { - ClearUnusedCacheFilesOperation operation = new ClearUnusedCacheFilesOperation(_packages); - OperationSystem.StartOperation(operation); - return operation; - } - /// /// 获取内置文件夹名称 /// diff --git a/Assets/YooAsset/Runtime/YooAssetsExtension.cs b/Assets/YooAsset/Runtime/YooAssetsExtension.cs index 2d26021..be0ceb5 100644 --- a/Assets/YooAsset/Runtime/YooAssetsExtension.cs +++ b/Assets/YooAsset/Runtime/YooAssetsExtension.cs @@ -367,14 +367,14 @@ namespace YooAsset #region 包裹更新 /// - /// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件 + /// 资源包裹更新,用于下载更新指定资源版本所有的资源包文件 /// /// 指定更新的包裹版本 /// 超时时间 - public static UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60) + public static DownloadPackageOperation DownloadPackageAsync(string packageVersion, int timeout = 60) { DebugCheckDefaultPackageValid(); - return _defaultPackage.UpdatePackageAsync(packageVersion, timeout); + return _defaultPackage.DownloadPackageAsync(packageVersion, timeout); } #endregion