From 8803003cf7b571c8bc1034c251acc4287e2123f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Tue, 31 Dec 2024 19:22:00 +0800 Subject: [PATCH] fix #432 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FileSystemParameters.RootDirectory字段重命名为PackageRoot --- .../DefaultBuildinFileSystem.cs | 15 ++++++------ .../DefaultBuildinFileSystemBuild.cs | 3 ++- .../Operation/DBFSInitializeOperation.cs | 3 +-- .../DefaultCacheFileSystem.cs | 21 +++++++++------- .../DefaultEditorFileSystem.cs | 7 +++--- .../DefaultWebRemoteFileSystem.cs | 2 +- .../DefaultWebServerFileSystem.cs | 15 ++++++------ .../FileSystem/FileSystemParameters.cs | 24 ++++++++----------- .../FileSystem/Interface/IFileSystem.cs | 4 ++-- 9 files changed, 48 insertions(+), 46 deletions(-) diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs index c40bdae8..a5a3b9b0 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs @@ -156,14 +156,14 @@ namespace YooAsset YooLogger.Warning($"Invalid parameter : {name}"); } } - public virtual void OnCreate(string packageName, string rootDirectory) + public virtual void OnCreate(string packageName, string packageRoot) { PackageName = packageName; - if (string.IsNullOrEmpty(rootDirectory)) - rootDirectory = GetDefaultBuildinRoot(); - - _packageRoot = PathUtility.Combine(rootDirectory, packageName); + if (string.IsNullOrEmpty(packageRoot)) + _packageRoot = GetDefaultBuildinPackageRoot(packageName); + else + _packageRoot = packageRoot; // 创建解压文件系统 var remoteServices = new DefaultUnpackRemoteServices(_packageRoot); @@ -282,9 +282,10 @@ namespace YooAsset } #region 内部方法 - protected string GetDefaultBuildinRoot() + protected string GetDefaultBuildinPackageRoot(string packageName) { - return YooAssetSettingsData.GetYooMobileBuildinRoot(); + string rootDirectory = YooAssetSettingsData.GetYooMobileBuildinRoot(); + return PathUtility.Combine(rootDirectory, packageName); } public string GetBuildinFileLoadPath(PackageBundle bundle) { diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystemBuild.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystemBuild.cs index 647e4ea9..0a3ec184 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystemBuild.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystemBuild.cs @@ -26,7 +26,8 @@ namespace YooAsset DirectoryInfo rootDirectory = new DirectoryInfo(rootPath); if (rootDirectory.Exists == false) { - throw new System.Exception($"Can not found StreamingAssets root directory : {rootPath}"); + UnityEngine.Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}"); + return; } // 搜索所有Package目录 diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSInitializeOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSInitializeOperation.cs index aa680f1b..b8bab890 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSInitializeOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSInitializeOperation.cs @@ -73,8 +73,7 @@ namespace YooAsset #if UNITY_EDITOR // 兼容性初始化 // 说明:内置文件系统在编辑器下运行时需要动态生成 - string buildinRoot = YooAssetSettingsData.GetYooEditorBuildinRoot(); - string packageRoot = PathUtility.Combine(buildinRoot, _fileSystem.PackageName); + string packageRoot = _fileSystem.FileRoot; DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot); #endif diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs index b8932b13..999a41f1 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs @@ -208,14 +208,15 @@ namespace YooAsset YooLogger.Warning($"Invalid parameter : {name}"); } } - public virtual void OnCreate(string packageName, string rootDirectory) + public virtual void OnCreate(string packageName, string packageRoot) { PackageName = packageName; - if (string.IsNullOrEmpty(rootDirectory)) - rootDirectory = GetDefaultCacheRoot(); + if (string.IsNullOrEmpty(packageRoot)) + _packageRoot = GetDefaultCachePackageRoot(packageName); + else + _packageRoot = packageRoot; - _packageRoot = PathUtility.Combine(rootDirectory, packageName); _cacheFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.SaveFilesFolderName); _tempFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName); _manifestFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName); @@ -462,15 +463,19 @@ namespace YooAsset #endregion #region 内部方法 - public string GetDefaultCacheRoot() + public string GetDefaultCachePackageRoot(string packageName) { + string rootDirectory; + #if UNITY_EDITOR - return YooAssetSettingsData.GetYooEditorCacheRoot(); + rootDirectory = YooAssetSettingsData.GetYooEditorCacheRoot(); #elif UNITY_STANDALONE - return YooAssetSettingsData.GetYooStandaloneCacheRoot(); + rootDirectory = YooAssetSettingsData.GetYooStandaloneCacheRoot(); #else - return YooAssetSettingsData.GetYooMobileCacheRoot(); + rootDirectory = YooAssetSettingsData.GetYooMobileCacheRoot(); #endif + + return PathUtility.Combine(rootDirectory, packageName); } public string GetCacheFileLoadPath(PackageBundle bundle) { diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs index fd719968..0b99f1f2 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs @@ -111,15 +111,14 @@ namespace YooAsset YooLogger.Warning($"Invalid parameter : {name}"); } } - public virtual void OnCreate(string packageName, string rootDirectory) + public virtual void OnCreate(string packageName, string packageRoot) { PackageName = packageName; - if (string.IsNullOrEmpty(rootDirectory)) + if (string.IsNullOrEmpty(packageRoot)) throw new Exception($"{nameof(DefaultEditorFileSystem)} root directory is null or empty !"); - // 注意:基础目录即为包裹目录 - _packageRoot = rootDirectory; + _packageRoot = packageRoot; } public virtual void OnUpdate() { diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/DefaultWebRemoteFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/DefaultWebRemoteFileSystem.cs index 184e5b71..5b4bb498 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/DefaultWebRemoteFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/DefaultWebRemoteFileSystem.cs @@ -113,7 +113,7 @@ namespace YooAsset YooLogger.Warning($"Invalid parameter : {name}"); } } - public virtual void OnCreate(string packageName, string rootDirectory) + public virtual void OnCreate(string packageName, string packageRoot) { PackageName = packageName; } diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs index 73bdbdf5..0da887ab 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs @@ -118,14 +118,14 @@ namespace YooAsset YooLogger.Warning($"Invalid parameter : {name}"); } } - public virtual void OnCreate(string packageName, string rootDirectory) + public virtual void OnCreate(string packageName, string packageRoot) { PackageName = packageName; - if (string.IsNullOrEmpty(rootDirectory)) - rootDirectory = GetDefaultWebRoot(); - - _webPackageRoot = PathUtility.Combine(rootDirectory, packageName); + if (string.IsNullOrEmpty(packageRoot)) + _webPackageRoot = GetDefaultWebPackageRoot(packageName); + else + _webPackageRoot = packageRoot; } public virtual void OnUpdate() { @@ -166,9 +166,10 @@ namespace YooAsset } #region 内部方法 - protected string GetDefaultWebRoot() + protected string GetDefaultWebPackageRoot(string packageName) { - return YooAssetSettingsData.GetYooWebBuildinRoot(); + string rootDirectory = YooAssetSettingsData.GetYooWebBuildinRoot(); + return PathUtility.Combine(rootDirectory, packageName); } public string GetWebFileLoadPath(PackageBundle bundle) { diff --git a/Assets/YooAsset/Runtime/FileSystem/FileSystemParameters.cs b/Assets/YooAsset/Runtime/FileSystem/FileSystemParameters.cs index 52c24917..80901585 100644 --- a/Assets/YooAsset/Runtime/FileSystem/FileSystemParameters.cs +++ b/Assets/YooAsset/Runtime/FileSystem/FileSystemParameters.cs @@ -20,13 +20,13 @@ namespace YooAsset /// /// 文件系统的根目录 /// - public string RootDirectory { private set; get; } + public string PackageRoot { private set; get; } - public FileSystemParameters(string fileSystemClass, string rootDirectory) + public FileSystemParameters(string fileSystemClass, string packageRoot) { FileSystemClass = fileSystemClass; - RootDirectory = rootDirectory; + PackageRoot = packageRoot; } /// @@ -62,7 +62,7 @@ namespace YooAsset { instance.SetParameter(param.Key, param.Value); } - instance.OnCreate(packageName, RootDirectory); + instance.OnCreate(packageName, PackageRoot); return instance; } @@ -82,14 +82,12 @@ namespace YooAsset /// 创建默认的内置文件系统参数 /// /// 加密文件解密服务类 - /// 缓存文件的校验等级 - /// 内置文件的根路径 - public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null) + /// 内置文件的根路径 + public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, string packageRoot = null) { string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName; - var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory); + var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices); - fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel); return fileSystemParams; } @@ -98,15 +96,13 @@ namespace YooAsset /// /// 远端资源地址查询服务类 /// 加密文件解密服务类 - /// 缓存文件的校验等级 - /// 文件系统的根目录 - public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null) + /// 文件系统的根目录 + public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, string packageRoot = null) { string fileSystemClass = typeof(DefaultCacheFileSystem).FullName; - var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory); + var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot); fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices); fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices); - fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel); return fileSystemParams; } diff --git a/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs index c7df5ccc..9e7566ad 100644 --- a/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs @@ -54,11 +54,11 @@ namespace YooAsset /// 设置自定义参数 /// void SetParameter(string name, object value); - + /// /// 创建缓存系统 /// - void OnCreate(string packageName, string rootDirectory); + void OnCreate(string packageName, string packageRoot); /// /// 更新文件系统