From 1f3e55ebeabcfccf0c8f3c8cd5a56a527213b270 Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 25 Oct 2022 14:33:21 +0800 Subject: [PATCH] Update DownloadSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 下载错误提示增加HTTP Response Code --- .../Runtime/DownloadSystem/Downloader/DownloaderBase.cs | 3 ++- .../Runtime/DownloadSystem/Downloader/FileDownloader.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs index 8d7c3ce..22e6d9e 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/DownloaderBase.cs @@ -24,6 +24,7 @@ namespace YooAsset protected string _requestURL; protected string _lastError = string.Empty; + protected long _lastCode = 0; protected float _downloadProgress = 0f; protected ulong _downloadedBytes = 0; @@ -119,7 +120,7 @@ namespace YooAsset /// public string GetLastError() { - return $"Failed to download : {_requestURL} Error : {_lastError}"; + return $"Failed to download : {_requestURL} Error : {_lastError} Code : {_lastCode}"; } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs index 30c2967..a80b403 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs @@ -134,12 +134,14 @@ namespace YooAsset { hasError = true; _lastError = _webRequest.error; + _lastCode = _webRequest.responseCode; } #else if (_webRequest.isNetworkError || _webRequest.isHttpError) { hasError = true; _lastError = _webRequest.error; + _lastCode = _webRequest.responseCode; } #endif @@ -151,6 +153,7 @@ namespace YooAsset { hasError = true; _lastError = $"Verify bundle content failed : {_bundleInfo.Bundle.FileName}"; + _lastCode = _webRequest.responseCode; // 验证失败后删除文件 string cacheFilePath = _bundleInfo.Bundle.CachedFilePath; @@ -198,6 +201,7 @@ namespace YooAsset else { _lastError = string.Empty; + _lastCode = 0; _steps = ESteps.Succeed; } @@ -223,6 +227,7 @@ namespace YooAsset { _steps = ESteps.Failed; _lastError = "user abort"; + _lastCode = 0; DisposeWebRequest(); } }