pull/189/head
hevinci 2023-10-10 11:59:56 +08:00
parent a25d03f073
commit b3a135e1a2
2 changed files with 6 additions and 5 deletions

View File

@ -78,6 +78,7 @@ namespace YooAsset
internal abstract void Start(); internal abstract void Start();
internal abstract void Update(); internal abstract void Update();
internal virtual void Abort() { }
internal void SetPackageName(string packageName) internal void SetPackageName(string packageName)
{ {
@ -90,6 +91,7 @@ namespace YooAsset
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "user abort"; Error = "user abort";
YooLogger.Warning($"Async operaiton has been abort : {this.GetType().Name}"); YooLogger.Warning($"Async operaiton has been abort : {this.GetType().Name}");
Abort();
} }
} }
internal void SetFinish() internal void SetFinish()
@ -102,6 +104,7 @@ namespace YooAsset
internal void SetStart() internal void SetStart()
{ {
Status = EOperationStatus.Processing; Status = EOperationStatus.Processing;
Start();
} }
/// <summary> /// <summary>

View File

@ -59,16 +59,15 @@ namespace YooAsset
break; break;
var operation = _operations[i]; var operation = _operations[i];
if (operation.IsDone == false)
operation.Update();
if (operation.IsDone) if (operation.IsDone)
{ {
// 注意:如果业务端发生异常,保证异步操作提前移除。 // 注意:如果业务端发生异常,保证异步操作提前移除。
_operations.RemoveAt(i); _operations.RemoveAt(i);
operation.SetFinish(); operation.SetFinish();
} }
else
{
operation.Update();
}
} }
} }
@ -116,7 +115,6 @@ namespace YooAsset
_newList.Add(operation); _newList.Add(operation);
operation.SetPackageName(packageName); operation.SetPackageName(packageName);
operation.SetStart(); operation.SetStart();
operation.Start();
} }
} }
} }