diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs index 946b9ab9..3f833112 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs @@ -126,7 +126,7 @@ namespace YooAsset public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) { // 注意:业务层的解压下载器会依赖内置文件系统的下载方法 - options.LocalFilePath = GetBuildinFileLoadPath(bundle); + options.ImportFilePath = GetBuildinFileLoadPath(bundle); return _unpackFileSystem.DownloadFileAsync(bundle, options); } public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs index 9523ed52..67eda71c 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs @@ -82,15 +82,31 @@ namespace YooAsset return oldDownloader; } - // 创建新的下载器 - DefaultDownloadFileOperation newDownloader; - if (string.IsNullOrEmpty(options.LocalFilePath)) + // 获取下载地址 + if (string.IsNullOrEmpty(options.ImportFilePath)) { - // 远端下载地址 + // 注意:如果是解压文件系统类,这里会返回本地内置文件的下载路径 options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName); options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(bundle.FileName); + } + else + { + // 注意:把本地导入文件路径转换为下载器请求地址 + options.MainURL = DownloadSystemHelper.ConvertToWWWPath(options.ImportFilePath); + options.FallbackURL = options.MainURL; + } - // 创建新的下载器 + // 创建新的下载器 + DefaultDownloadFileOperation newDownloader; + bool isRequestLocalFile = DownloadSystemHelper.IsRequestLocalFile(options.MainURL); + if (isRequestLocalFile) + { + newDownloader = new DownloadLocalFileOperation(_fileSystem, bundle, options); + AddChildOperation(newDownloader); + _downloaders.Add(bundle.BundleGUID, newDownloader); + } + else + { if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize) { newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, options); @@ -104,18 +120,6 @@ namespace YooAsset _downloaders.Add(bundle.BundleGUID, newDownloader); } } - else - { - // 注意:把本地文件路径指定为可下载地址 - options.MainURL = DownloadSystemHelper.ConvertToWWWPath(options.LocalFilePath); - options.FallbackURL = options.MainURL; - - // 创建新的下载器 - newDownloader = new DownloadLocalFileOperation(_fileSystem, bundle, options); - AddChildOperation(newDownloader); - _downloaders.Add(bundle.BundleGUID, newDownloader); - } - return newDownloader; } diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs index 8204017c..4ddf5f74 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs @@ -159,9 +159,12 @@ namespace YooAsset { if (ExecuteWhileDone()) { - //TODO 同步加载失败 + //TODO 尝试同步加载远端的资源文件失败 if (Status == EOperationStatus.Failed) + { YooLogger.Error($"Try load bundle {Bundle.BundleName} from remote !"); + YooLogger.Error($"The load remote bundle url : {_requestURL}"); + } _steps = ESteps.Done; break; diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs index c6ef2ba0..c18fe924 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs @@ -177,9 +177,12 @@ namespace YooAsset { if (ExecuteWhileDone()) { - //TODO 同步加载失败 + //TODO 尝试同步加载远端的资源文件失败 if (Status == EOperationStatus.Failed) + { YooLogger.Error($"Try load bundle {Bundle.BundleName} from remote !"); + YooLogger.Error($"The load remote bundle url : {_requestURL}"); + } _steps = ESteps.Done; break; diff --git a/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs index 1aa6319f..9703683c 100644 --- a/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs @@ -26,7 +26,7 @@ namespace YooAsset /// /// 拷贝的本地文件路径 /// - public string LocalFilePath { set; get; } + public string ImportFilePath { set; get; } public DownloadFileOptions(int failedTryAgain, int timeout) { diff --git a/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs b/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs index ec9cc439..09a6db29 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs @@ -39,7 +39,7 @@ namespace YooAsset public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout) { DownloadFileOptions options = new DownloadFileOptions(failedTryAgain, timeout); - options.LocalFilePath = _importFilePath; + options.ImportFilePath = _importFilePath; return _fileSystem.DownloadFileAsync(Bundle, options); }