From 37f0d1e5a1975bb5045a8a87048e63ea51fedcd4 Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 12 May 2023 17:32:41 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增方法YooAssets.SetCacheSystemSandboxPath() --- .../Internal/FindCacheFilesOperation.cs | 4 +- .../PersistentTools.cs} | 110 +++++++++--------- .../PersistentTools.cs.meta} | 0 .../Runtime/PackageSystem/ManifestTools.cs | 2 +- .../Operations/InitializationOperation.cs | 6 +- .../Internal/DownloadManifestOperation.cs | 4 +- .../Internal/LoadBuildinManifestOperation.cs | 4 +- .../Internal/LoadCacheManifestOperation.cs | 4 +- .../QueryBuildinPackageVersionOperation.cs | 4 +- .../QueryCachePackageHashOperation.cs | 2 +- .../QueryCachePackageVersionOperation.cs | 2 +- .../UnpackBuildinManifestOperation.cs | 12 +- .../Runtime/PackageSystem/PackageBundle.cs | 10 +- .../PlayMode/HostPlayModeImpl.cs | 2 +- Assets/YooAsset/Runtime/YooAssets.cs | 25 +++- 15 files changed, 109 insertions(+), 82 deletions(-) rename Assets/YooAsset/Runtime/{Utility/YooHelper.cs => CacheSystem/PersistentTools.cs} (84%) rename Assets/YooAsset/Runtime/{Utility/YooHelper.cs.meta => CacheSystem/PersistentTools.cs.meta} (100%) diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs index b442ed1..f6bd2ef 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/Internal/FindCacheFilesOperation.cs @@ -45,7 +45,7 @@ namespace YooAsset { // BundleFiles { - string rootPath = PersistentHelper.GetCachedBundleFileFolderPath(_packageName); + string rootPath = PersistentTools.GetCachedBundleFileFolderPath(_packageName); DirectoryInfo rootDirectory = new DirectoryInfo(rootPath); if (rootDirectory.Exists) { @@ -56,7 +56,7 @@ namespace YooAsset // RawFiles { - string rootPath = PersistentHelper.GetCachedRawFileFolderPath(_packageName); + string rootPath = PersistentTools.GetCachedRawFileFolderPath(_packageName); DirectoryInfo rootDirectory = new DirectoryInfo(rootPath); if (rootDirectory.Exists) { diff --git a/Assets/YooAsset/Runtime/Utility/YooHelper.cs b/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs similarity index 84% rename from Assets/YooAsset/Runtime/Utility/YooHelper.cs rename to Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs index 25a03d2..ceb7eed 100644 --- a/Assets/YooAsset/Runtime/Utility/YooHelper.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs @@ -3,14 +3,59 @@ using System.Collections.Generic; namespace YooAsset { - /// - /// 资源路径帮助类 - /// - internal static class PathHelper + internal static class PersistentTools { + private const string CacheFolderName = "CacheFiles"; + private const string CachedBundleFileFolder = "BundleFiles"; + private const string CachedRawFileFolder = "RawFiles"; + private const string ManifestFolderName = "ManifestFiles"; + private const string AppFootPrintFileName = "ApplicationFootPrint.bytes"; + private static string _buildinPath; private static string _sandboxPath; + + /// + /// 重写沙盒跟路径 + /// + public static void OverwriteSandboxPath(string sandboxPath) + { + _sandboxPath = sandboxPath; + } + + /// + /// 获取沙盒文件夹路径 + /// + public static string GetPersistentRootPath() + { +#if UNITY_EDITOR + // 注意:为了方便调试查看,编辑器下把存储目录放到项目里 + if (string.IsNullOrEmpty(_sandboxPath)) + { + string directory = Path.GetDirectoryName(UnityEngine.Application.dataPath); + string projectPath = GetRegularPath(directory); + _sandboxPath = StringUtility.Format("{0}/Sandbox", projectPath); + } +#elif UNITY_STANDALONE + if (string.IsNullOrEmpty(_sandboxPath)) + { + _sandboxPath = StringUtility.Format("{0}/Sandbox", UnityEngine.Application.dataPath); + } +#else + if (string.IsNullOrEmpty(_sandboxPath)) + { + _sandboxPath = StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath); + } +#endif + + return _sandboxPath; + } + private static string GetRegularPath(string path) + { + return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式 + } + + /// /// 获取基于流文件夹的加载路径 /// @@ -32,33 +77,6 @@ namespace YooAsset return StringUtility.Format("{0}/{1}", root, path); } - /// - /// 获取沙盒文件夹路径 - /// - public static string GetPersistentRootPath() - { -#if UNITY_EDITOR - // 注意:为了方便调试查看,编辑器下把存储目录放到项目里 - if (string.IsNullOrEmpty(_sandboxPath)) - { - string directory = Path.GetDirectoryName(UnityEngine.Application.dataPath); - string projectPath = GetRegularPath(directory); - _sandboxPath = StringUtility.Format("{0}/Sandbox", projectPath); - } - return _sandboxPath; -#else - if (string.IsNullOrEmpty(_sandboxPath)) - { - _sandboxPath = StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath); - } - return _sandboxPath; -#endif - } - private static string GetRegularPath(string path) - { - return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式 - } - /// /// 获取WWW加载本地资源的路径 /// @@ -76,18 +94,6 @@ namespace YooAsset return path; #endif } - } - - /// - /// 持久化目录帮助类 - /// - internal static class PersistentHelper - { - private const string CacheFolderName = "CacheFiles"; - private const string CachedBundleFileFolder = "BundleFiles"; - private const string CachedRawFileFolder = "RawFiles"; - private const string ManifestFolderName = "ManifestFiles"; - private const string AppFootPrintFileName = "ApplicationFootPrint.bytes"; /// @@ -95,7 +101,7 @@ namespace YooAsset /// public static void DeleteSandbox() { - string directoryPath = PathHelper.MakePersistentLoadPath(string.Empty); + string directoryPath = MakePersistentLoadPath(string.Empty); if (Directory.Exists(directoryPath)) Directory.Delete(directoryPath, true); } @@ -105,7 +111,7 @@ namespace YooAsset /// public static void DeleteCacheFolder() { - string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + string root = MakePersistentLoadPath(CacheFolderName); if (Directory.Exists(root)) Directory.Delete(root, true); } @@ -115,7 +121,7 @@ namespace YooAsset /// public static void DeleteManifestFolder() { - string root = PathHelper.MakePersistentLoadPath(ManifestFolderName); + string root = MakePersistentLoadPath(ManifestFolderName); if (Directory.Exists(root)) Directory.Delete(root, true); } @@ -129,7 +135,7 @@ namespace YooAsset { if (_cachedBundleFileFolder.TryGetValue(packageName, out string value) == false) { - string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + string root = MakePersistentLoadPath(CacheFolderName); value = $"{root}/{packageName}/{CachedBundleFileFolder}"; _cachedBundleFileFolder.Add(packageName, value); } @@ -144,7 +150,7 @@ namespace YooAsset { if (_cachedRawFileFolder.TryGetValue(packageName, out string value) == false) { - string root = PathHelper.MakePersistentLoadPath(CacheFolderName); + string root = MakePersistentLoadPath(CacheFolderName); value = $"{root}/{packageName}/{CachedRawFileFolder}"; _cachedRawFileFolder.Add(packageName, value); } @@ -156,7 +162,7 @@ namespace YooAsset /// public static string GetAppFootPrintFilePath() { - return PathHelper.MakePersistentLoadPath(AppFootPrintFileName); + return MakePersistentLoadPath(AppFootPrintFileName); } /// @@ -165,7 +171,7 @@ namespace YooAsset public static string GetCacheManifestFilePath(string packageName, string packageVersion) { string fileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion); - return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}"); + return MakePersistentLoadPath($"{ManifestFolderName}/{fileName}"); } /// @@ -174,7 +180,7 @@ namespace YooAsset public static string GetCachePackageHashFilePath(string packageName, string packageVersion) { string fileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion); - return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}"); + return MakePersistentLoadPath($"{ManifestFolderName}/{fileName}"); } /// @@ -183,7 +189,7 @@ namespace YooAsset public static string GetCachePackageVersionFilePath(string packageName) { string fileName = YooAssetSettingsData.GetPackageVersionFileName(packageName); - return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}"); + return MakePersistentLoadPath($"{ManifestFolderName}/{fileName}"); } /// diff --git a/Assets/YooAsset/Runtime/Utility/YooHelper.cs.meta b/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs.meta similarity index 100% rename from Assets/YooAsset/Runtime/Utility/YooHelper.cs.meta rename to Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs.meta diff --git a/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs b/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs index 107bce9..1494db3 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs @@ -193,7 +193,7 @@ namespace YooAsset public static BundleInfo GetUnpackInfo(PackageBundle packageBundle) { // 注意:我们把流加载路径指定为远端下载地址 - string streamingPath = PathHelper.ConvertToWWWPath(packageBundle.StreamingFilePath); + string streamingPath = PersistentTools.ConvertToWWWPath(packageBundle.StreamingFilePath); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath); return bundleInfo; } diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs index 8683be6..f21c10f 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs @@ -222,7 +222,7 @@ namespace YooAsset // 如果水印发生变化,则说明覆盖安装后首次打开游戏 if (appFootPrint.IsDirty()) { - PersistentHelper.DeleteManifestFolder(); + PersistentTools.DeleteManifestFolder(); appFootPrint.Coverage(); YooLogger.Log("Delete manifest files when application foot print dirty !"); } @@ -376,7 +376,7 @@ namespace YooAsset /// public void Load() { - string footPrintFilePath = PersistentHelper.GetAppFootPrintFilePath(); + string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath(); if (File.Exists(footPrintFilePath)) { _footPrint = FileUtility.ReadAllText(footPrintFilePath); @@ -409,7 +409,7 @@ namespace YooAsset #else _footPrint = Application.buildGUID; #endif - string footPrintFilePath = PersistentHelper.GetAppFootPrintFilePath(); + string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath(); FileUtility.CreateFile(footPrintFilePath, _footPrint); YooLogger.Log($"Save application foot print : {_footPrint}"); } diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DownloadManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DownloadManifestOperation.cs index 0707fe7..27d3546 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DownloadManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DownloadManifestOperation.cs @@ -41,7 +41,7 @@ namespace YooAsset { if (_downloader1 == null) { - string savePath = PersistentHelper.GetCachePackageHashFilePath(_packageName, _packageVersion); + string savePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion); string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion); string webURL = GetDownloadRequestURL(fileName); YooLogger.Log($"Beginning to download package hash file : {webURL}"); @@ -71,7 +71,7 @@ namespace YooAsset { if (_downloader2 == null) { - string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName, _packageVersion); + string savePath = PersistentTools.GetCacheManifestFilePath(_packageName, _packageVersion); string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion); string webURL = GetDownloadRequestURL(fileName); YooLogger.Log($"Beginning to download manifest file : {webURL}"); diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadBuildinManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadBuildinManifestOperation.cs index 3791262..682aec9 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadBuildinManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadBuildinManifestOperation.cs @@ -42,8 +42,8 @@ namespace YooAsset if (_downloader == null) { string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion); - string filePath = PathHelper.MakeStreamingLoadPath(fileName); - string url = PathHelper.ConvertToWWWPath(filePath); + string filePath = PersistentTools.MakeStreamingLoadPath(fileName); + string url = PersistentTools.ConvertToWWWPath(filePath); _downloader = new UnityWebDataRequester(); _downloader.SendRequest(url); } diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs index 708d395..dcfdb53 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs @@ -67,7 +67,7 @@ namespace YooAsset if (_steps == ESteps.VerifyFileHash) { - _manifestFilePath = PersistentHelper.GetCacheManifestFilePath(_packageName, _packageVersion); + _manifestFilePath = PersistentTools.GetCacheManifestFilePath(_packageName, _packageVersion); if (File.Exists(_manifestFilePath) == false) { _steps = ESteps.Done; @@ -131,7 +131,7 @@ namespace YooAsset File.Delete(_manifestFilePath); } - string hashFilePath = PersistentHelper.GetCachePackageHashFilePath(_packageName, _packageVersion); + string hashFilePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion); if (File.Exists(hashFilePath)) { File.Delete(hashFilePath); diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryBuildinPackageVersionOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryBuildinPackageVersionOperation.cs index 046793e..be0d8ef 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryBuildinPackageVersionOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryBuildinPackageVersionOperation.cs @@ -38,8 +38,8 @@ namespace YooAsset if (_downloader == null) { string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName); - string filePath = PathHelper.MakeStreamingLoadPath(fileName); - string url = PathHelper.ConvertToWWWPath(filePath); + string filePath = PersistentTools.MakeStreamingLoadPath(fileName); + string url = PersistentTools.ConvertToWWWPath(filePath); _downloader = new UnityWebDataRequester(); _downloader.SendRequest(url); } diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageHashOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageHashOperation.cs index 80caaab..62f00c5 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageHashOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageHashOperation.cs @@ -37,7 +37,7 @@ namespace YooAsset if (_steps == ESteps.LoadCachePackageHashFile) { - string filePath = PersistentHelper.GetCachePackageHashFilePath(_packageName, _packageVersion); + string filePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion); if (File.Exists(filePath) == false) { _steps = ESteps.Done; diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageVersionOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageVersionOperation.cs index c56a767..d948c6a 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageVersionOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/QueryCachePackageVersionOperation.cs @@ -35,7 +35,7 @@ namespace YooAsset if (_steps == ESteps.LoadCachePackageVersionFile) { - string filePath = PersistentHelper.GetCachePackageVersionFilePath(_packageName); + string filePath = PersistentTools.GetCachePackageVersionFilePath(_packageName); if (File.Exists(filePath) == false) { _steps = ESteps.Done; diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/UnpackBuildinManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/UnpackBuildinManifestOperation.cs index beadbe1..b000e4b 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/UnpackBuildinManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/UnpackBuildinManifestOperation.cs @@ -35,10 +35,10 @@ namespace YooAsset { if (_downloader1 == null) { - string savePath = PersistentHelper.GetCachePackageHashFilePath(_buildinPackageName, _buildinPackageVersion); + string savePath = PersistentTools.GetCachePackageHashFilePath(_buildinPackageName, _buildinPackageVersion); string fileName = YooAssetSettingsData.GetPackageHashFileName(_buildinPackageName, _buildinPackageVersion); - string filePath = PathHelper.MakeStreamingLoadPath(fileName); - string url = PathHelper.ConvertToWWWPath(filePath); + string filePath = PersistentTools.MakeStreamingLoadPath(fileName); + string url = PersistentTools.ConvertToWWWPath(filePath); _downloader1 = new UnityWebFileRequester(); _downloader1.SendRequest(url, savePath); } @@ -64,10 +64,10 @@ namespace YooAsset { if (_downloader2 == null) { - string savePath = PersistentHelper.GetCacheManifestFilePath(_buildinPackageName, _buildinPackageVersion); + string savePath = PersistentTools.GetCacheManifestFilePath(_buildinPackageName, _buildinPackageVersion); string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion); - string filePath = PathHelper.MakeStreamingLoadPath(fileName); - string url = PathHelper.ConvertToWWWPath(filePath); + string filePath = PersistentTools.MakeStreamingLoadPath(fileName); + string url = PersistentTools.ConvertToWWWPath(filePath); _downloader2 = new UnityWebFileRequester(); _downloader2.SendRequest(url, savePath); } diff --git a/Assets/YooAsset/Runtime/PackageSystem/PackageBundle.cs b/Assets/YooAsset/Runtime/PackageSystem/PackageBundle.cs index 1b12a2a..4045a13 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PackageBundle.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PackageBundle.cs @@ -74,12 +74,12 @@ namespace YooAsset string folderName = FileHash.Substring(0, 2); if (IsRawFile) { - string cacheRoot = PersistentHelper.GetCachedRawFileFolderPath(PackageName); + string cacheRoot = PersistentTools.GetCachedRawFileFolderPath(PackageName); _cachedDataFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}{_fileExtension}"; } else { - string cacheRoot = PersistentHelper.GetCachedBundleFileFolderPath(PackageName); + string cacheRoot = PersistentTools.GetCachedBundleFileFolderPath(PackageName); _cachedDataFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}"; } return _cachedDataFilePath; @@ -100,12 +100,12 @@ namespace YooAsset string folderName = FileHash.Substring(0, 2); if (IsRawFile) { - string cacheRoot = PersistentHelper.GetCachedRawFileFolderPath(PackageName); + string cacheRoot = PersistentTools.GetCachedRawFileFolderPath(PackageName); _cachedInfoFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleInfoFileName}"; } else { - string cacheRoot = PersistentHelper.GetCachedBundleFileFolderPath(PackageName); + string cacheRoot = PersistentTools.GetCachedBundleFileFolderPath(PackageName); _cachedInfoFilePath = $"{cacheRoot}/{folderName}/{CacheGUID}/{YooAssetSettings.CacheBundleInfoFileName}"; } return _cachedInfoFilePath; @@ -139,7 +139,7 @@ namespace YooAsset if (string.IsNullOrEmpty(_streamingFilePath) == false) return _streamingFilePath; - _streamingFilePath = PathHelper.MakeStreamingLoadPath(FileName); + _streamingFilePath = PersistentTools.MakeStreamingLoadPath(FileName); return _streamingFilePath; } } diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs index fc79a6b..7eeda25 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs @@ -93,7 +93,7 @@ namespace YooAsset public void FlushManifestVersionFile() { if (_activeManifest != null) - PersistentHelper.SaveCachePackageVersionFile(_packageName, _activeManifest.PackageVersion); + PersistentTools.SaveCachePackageVersionFile(_packageName, _activeManifest.PackageVersion); } private bool IsBuildinPackageBundle(PackageBundle packageBundle) diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index cf93c23..3faf131 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -234,6 +234,27 @@ namespace YooAsset { CacheSystem.InitVerifyLevel = verifyLevel; } + + /// + /// 设置缓存系统参数,沙盒目录的存储路径 + /// + public static void SetCacheSystemSandboxPath(string sandboxPath) + { + if (string.IsNullOrEmpty(sandboxPath)) + { + YooLogger.Error($"Sandbox path is null or empty !"); + return; + } + + // 注意:需要确保没有任何资源系统起效之前才可以设置沙盒目录! + if (_packages.Count > 0) + { + YooLogger.Error($"Please call this method {nameof(SetCacheSystemSandboxPath)} before the package is created !"); + return; + } + + PersistentTools.OverwriteSandboxPath(sandboxPath); + } #endregion #region 沙盒相关 @@ -250,7 +271,7 @@ namespace YooAsset /// public static string GetSandboxRoot() { - return PathHelper.GetPersistentRootPath(); + return PersistentTools.GetPersistentRootPath(); } /// @@ -259,7 +280,7 @@ namespace YooAsset public static void ClearSandbox() { YooLogger.Warning("Clear sandbox folder files, Finally, restart the application !"); - PersistentHelper.DeleteSandbox(); + PersistentTools.DeleteSandbox(); } #endregion