From f375d45bd663ff5f47017ef40e4c058a3dbb006f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Thu, 8 Jan 2026 17:22:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=E9=87=8D=E6=9E=84=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=93=8D=E4=BD=9C=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OperationSystem/AsyncOperationBase.cs | 23 +++++++++++++++++-- .../OperationSystem/OperationScheduler.cs | 6 +++-- .../OperationSystem/OperationSystem.cs | 19 --------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs index 74746461..0d102753 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs @@ -224,12 +224,12 @@ namespace YooAsset InternalAbort(); Status = EOperationStatus.Failed; Error = "user abort"; - YooLogger.Warning($"Async operaiton {this.GetType().Name} has been abort !"); + YooLogger.Warning($"Async operation {this.GetType().Name} has been aborted !"); } } /// - /// 结束异步任务 + /// 强制结束异步任务 /// internal void FinishOperation() { @@ -348,6 +348,25 @@ namespace YooAsset float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f); return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00"); } + + internal DebugOperationInfo GetDebugOperationInfo() + { + var operationInfo = new DebugOperationInfo(); + operationInfo.OperationName = this.GetType().Name; + operationInfo.OperationDesc = GetOperationDesc(); + operationInfo.Priority = Priority; + operationInfo.Progress = Progress; + operationInfo.BeginTime = BeginTime; + operationInfo.ProcessTime = ProcessTime; + operationInfo.Status = Status.ToString(); + operationInfo.Childs = new List(Childs.Count); + foreach (var child in Childs) + { + var childInfo = child.GetDebugOperationInfo(); + operationInfo.Childs.Add(childInfo); + } + return operationInfo; + } #endregion #region 排序接口实现 diff --git a/Assets/YooAsset/Runtime/OperationSystem/OperationScheduler.cs b/Assets/YooAsset/Runtime/OperationSystem/OperationScheduler.cs index 3eabac6f..51463577 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/OperationScheduler.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/OperationScheduler.cs @@ -109,6 +109,7 @@ namespace YooAsset foreach (var operation in _newList) { operation.AbortOperation(); + operation.FinishOperation(); //注意:强制收尾,确保Task能完成 } _newList.Clear(); @@ -116,6 +117,7 @@ namespace YooAsset foreach (var operation in _operations) { operation.AbortOperation(); + operation.FinishOperation(); //注意:强制收尾,确保Task能完成 } _operations.Clear(); } @@ -131,14 +133,14 @@ namespace YooAsset // 包含正在执行的任务 foreach (var operation in _operations) { - var operationInfo = OperationSystem.GetDebugOperationInfo(operation); + var operationInfo = operation.GetDebugOperationInfo(); result.Add(operationInfo); } // 包含待处理的新任务 foreach (var operation in _newList) { - var operationInfo = OperationSystem.GetDebugOperationInfo(operation); + var operationInfo = operation.GetDebugOperationInfo(); result.Add(operationInfo); } diff --git a/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs index 50cb53e6..a5964487 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs @@ -229,25 +229,6 @@ namespace YooAsset return new List(); } - - internal static DebugOperationInfo GetDebugOperationInfo(AsyncOperationBase operation) - { - var operationInfo = new DebugOperationInfo(); - operationInfo.OperationName = operation.GetType().Name; - operationInfo.OperationDesc = operation.GetOperationDesc(); - operationInfo.Priority = operation.Priority; - operationInfo.Progress = operation.Progress; - operationInfo.BeginTime = operation.BeginTime; - operationInfo.ProcessTime = operation.ProcessTime; - operationInfo.Status = operation.Status.ToString(); - operationInfo.Childs = new List(operation.Childs.Count); - foreach (var child in operation.Childs) - { - var childInfo = GetDebugOperationInfo(child); - operationInfo.Childs.Add(childInfo); - } - return operationInfo; - } #endregion } }