mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
refactor : 重构异步操作模块
This commit is contained in:
@@ -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 !");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结束异步任务
|
||||
/// 强制结束异步任务
|
||||
/// </summary>
|
||||
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<DebugOperationInfo>(Childs.Count);
|
||||
foreach (var child in Childs)
|
||||
{
|
||||
var childInfo = child.GetDebugOperationInfo();
|
||||
operationInfo.Childs.Add(childInfo);
|
||||
}
|
||||
return operationInfo;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 排序接口实现
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,25 +229,6 @@ namespace YooAsset
|
||||
|
||||
return new List<DebugOperationInfo>();
|
||||
}
|
||||
|
||||
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<DebugOperationInfo>(operation.Childs.Count);
|
||||
foreach (var child in operation.Childs)
|
||||
{
|
||||
var childInfo = GetDebugOperationInfo(child);
|
||||
operationInfo.Childs.Add(childInfo);
|
||||
}
|
||||
return operationInfo;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user