update diagnostic system
This commit is contained in:
@@ -8,11 +8,15 @@ namespace YooAsset
|
||||
{
|
||||
public abstract class AsyncOperationBase : IEnumerator, IComparable<AsyncOperationBase>
|
||||
{
|
||||
private readonly List<AsyncOperationBase> _childs = new List<AsyncOperationBase>(10);
|
||||
private Action<AsyncOperationBase> _callback;
|
||||
private string _packageName = null;
|
||||
private int _whileFrame = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// 所有子任务
|
||||
/// </summary>
|
||||
internal readonly List<AsyncOperationBase> Childs = new List<AsyncOperationBase>(10);
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步执行完成
|
||||
/// </summary>
|
||||
@@ -109,6 +113,10 @@ namespace YooAsset
|
||||
{
|
||||
throw new System.NotImplementedException(this.GetType().Name);
|
||||
}
|
||||
internal virtual string InternalGetDesc()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置包裹名称
|
||||
@@ -124,11 +132,19 @@ namespace YooAsset
|
||||
internal void AddChildOperation(AsyncOperationBase child)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (_childs.Contains(child))
|
||||
if (Childs.Contains(child))
|
||||
throw new Exception($"The child node {child.GetType().Name} already exists !");
|
||||
#endif
|
||||
|
||||
_childs.Add(child);
|
||||
Childs.Add(child);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取异步操作说明
|
||||
/// </summary>
|
||||
internal string GetOperationDesc()
|
||||
{
|
||||
return InternalGetDesc();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -185,7 +201,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
internal void AbortOperation()
|
||||
{
|
||||
foreach (var child in _childs)
|
||||
foreach (var child in Childs)
|
||||
{
|
||||
child.AbortOperation();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public static void Update()
|
||||
{
|
||||
// 移除已经完成的异步操作
|
||||
// 注意:移除上一帧完成的异步操作,方便调试器接收到完整的信息!
|
||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var operation = _operations[i];
|
||||
if (operation.IsFinish)
|
||||
_operations.RemoveAt(i);
|
||||
}
|
||||
|
||||
// 添加新增的异步操作
|
||||
if (_newList.Count > 0)
|
||||
{
|
||||
@@ -77,14 +86,6 @@ namespace YooAsset
|
||||
|
||||
operation.UpdateOperation();
|
||||
}
|
||||
|
||||
// 移除已经完成的异步操作
|
||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var operation = _operations[i];
|
||||
if (operation.IsFinish)
|
||||
_operations.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -141,18 +142,30 @@ namespace YooAsset
|
||||
{
|
||||
if (operation.PackageName == packageName)
|
||||
{
|
||||
var operationInfo = new DebugOperationInfo();
|
||||
operationInfo.OperationName = operation.GetType().FullName;
|
||||
operationInfo.Priority = operation.Priority;
|
||||
operationInfo.Progress = operation.Progress;
|
||||
operationInfo.BeginTime = operation.BeginTime;
|
||||
operationInfo.ProcessTime = operation.ProcessTime;
|
||||
operationInfo.Status = operation.Status.ToString();
|
||||
var operationInfo = GetDebugOperationInfo(operation);
|
||||
result.Add(operationInfo);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
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