From f0563cce0bfdb3af08b363f71dcf28f8ff510efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Wed, 7 Jan 2026 15:52:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=E9=87=8D=E6=9E=84=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E4=B8=8B=E8=BD=BD=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UnityWebRequestAssetBundleDownloader.cs | 3 +++ .../YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs | 4 ++-- Assets/YooAsset/Runtime/DownloadSystem/README.md | 3 +-- Assets/YooAsset/Runtime/DownloadSystem/WebRequestCounter.cs | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DefaultDownloadRequest/UnityWebRequestAssetBundleDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/DefaultDownloadRequest/UnityWebRequestAssetBundleDownloader.cs index 8be0c9c2..feea31a9 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/DefaultDownloadRequest/UnityWebRequestAssetBundleDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/DefaultDownloadRequest/UnityWebRequestAssetBundleDownloader.cs @@ -75,6 +75,9 @@ namespace YooAsset } else { + if (string.IsNullOrEmpty(_args.FileHash)) + throw new YooInternalException("File hash is null or empty !"); + // 使用 Unity 缓存 // 说明:The file hash defining the version of the asset bundle. Hash128 fileHash = Hash128.Parse(_args.FileHash); diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs index f863affc..626840b6 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs @@ -57,7 +57,7 @@ namespace YooAsset #elif UNITY_STANDALONE_LINUX url = StringUtility.Format("file:///root/{0}", path); #else - throw new System.NotImplementedException(); + throw new System.NotSupportedException($"[{nameof(DownloadSystemHelper.ConvertToWWWPath)}] not implemented platform: {UnityEngine.Application.platform}"); #endif // For some special cases when users have special characters in their devices, url paths can not be identified correctly. @@ -82,4 +82,4 @@ namespace YooAsset return false; } } -} \ No newline at end of file +} diff --git a/Assets/YooAsset/Runtime/DownloadSystem/README.md b/Assets/YooAsset/Runtime/DownloadSystem/README.md index 26cdff6c..1f857d95 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/README.md +++ b/Assets/YooAsset/Runtime/DownloadSystem/README.md @@ -530,9 +530,8 @@ VirtualFileDownloader (独立实现) ──► IDownloadFileRequest 提供跨平台的工具函数: -| 成员 | 说明 | +| 方法 | 说明 | |------|------| -| `UnityWebRequestCreater` | 兼容保留的全局 UnityWebRequest 创建委托(默认文件系统不再读取,推荐改为 FileSystemParameters 注入) | | `ConvertToWWWPath()` | 转换本地路径为 WWW 协议 URL | | `IsRequestLocalFile()` | 判断是否本地文件请求 | diff --git a/Assets/YooAsset/Runtime/DownloadSystem/WebRequestCounter.cs b/Assets/YooAsset/Runtime/DownloadSystem/WebRequestCounter.cs index e06c7cfc..ca9af545 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/WebRequestCounter.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/WebRequestCounter.cs @@ -41,9 +41,9 @@ namespace YooAsset public static int GetRequestFailedCount(string packageName, string eventName) { string key = $"{packageName}_{eventName}"; - if (_requestFailedRecorder.ContainsKey(key) == false) - _requestFailedRecorder.Add(key, 0); - return _requestFailedRecorder[key]; + if (_requestFailedRecorder.TryGetValue(key, out int count)) + return count; + return 0; } } }