From 236468b4a86b64277f3e5ee6c395c5c13d64595e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Wed, 9 Jul 2025 14:52:22 +0800 Subject: [PATCH] update download system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构下载逻辑代码 --- .../Internal/UnityAssetBundleRequestOperation.cs | 5 ----- .../Internal/UnityWebDataRequestOperation.cs | 5 ----- .../Internal/UnityWebFileRequestOperation.cs | 5 ----- .../Operation/Internal/UnityWebRequestOperation.cs | 14 ++++++++++++++ .../Internal/UnityWebTextRequestOperation.cs | 5 ----- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityAssetBundleRequestOperation.cs b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityAssetBundleRequestOperation.cs index 25d98ebe..621f2702 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityAssetBundleRequestOperation.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityAssetBundleRequestOperation.cs @@ -82,11 +82,6 @@ namespace YooAsset DisposeRequest(); } } - internal override void InternalAbort() - { - _steps = ESteps.Done; - DisposeRequest(); - } private void CreateWebRequest() { diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebDataRequestOperation.cs b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebDataRequestOperation.cs index d7635b5e..d0ad4b69 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebDataRequestOperation.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebDataRequestOperation.cs @@ -80,11 +80,6 @@ namespace YooAsset DisposeRequest(); } } - internal override void InternalAbort() - { - _steps = ESteps.Done; - DisposeRequest(); - } /// /// 不检测超时 diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebFileRequestOperation.cs b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebFileRequestOperation.cs index d81d2c7b..acc90fbe 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebFileRequestOperation.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebFileRequestOperation.cs @@ -64,11 +64,6 @@ namespace YooAsset DisposeRequest(); } } - internal override void InternalAbort() - { - _steps = ESteps.Done; - DisposeRequest(); - } private void CreateWebRequest() { diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebRequestOperation.cs b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebRequestOperation.cs index 4db73f98..a1c03e6b 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebRequestOperation.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebRequestOperation.cs @@ -43,6 +43,20 @@ namespace YooAsset _requestURL = url; _timeout = timeout; } + internal override void InternalAbort() + { + //TODO + // 1. 编辑器下停止运行游戏的时候主动终止下载任务 + // 2. 真机上销毁包裹的时候主动终止下载任务 + if (_isAbort == false) + { + if (_webRequest != null) + { + _webRequest.Abort(); + _isAbort = true; + } + } + } /// /// 释放下载器 diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebTextRequestOperation.cs b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebTextRequestOperation.cs index 8395d10a..a57a3f92 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebTextRequestOperation.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebTextRequestOperation.cs @@ -78,11 +78,6 @@ namespace YooAsset DisposeRequest(); } } - internal override void InternalAbort() - { - _steps = ESteps.Done; - DisposeRequest(); - } private void CreateWebRequest() {