update operation system

Operation状态增加Processing处理中状态
mlyDevMerge1.5.7
hevinci 2023-08-11 16:20:38 +08:00 committed by QiJing
parent 15c57ac3fc
commit f783fd42bc
4 changed files with 18 additions and 7 deletions

View File

@ -44,12 +44,16 @@ namespace YooAsset
{
if (IsValidWithWarning == false)
return EOperationStatus.None;
if (Provider.Status == ProviderBase.EStatus.Failed)
return EOperationStatus.Failed;
else if (Provider.Status == ProviderBase.EStatus.Succeed)
return EOperationStatus.Succeed;
else
var status = Provider.Status;
if (status == ProviderBase.EStatus.None)
return EOperationStatus.None;
else if (status == ProviderBase.EStatus.Succeed)
return EOperationStatus.Succeed;
else if (status == ProviderBase.EStatus.Failed)
return EOperationStatus.Failed;
else
return EOperationStatus.Processing;
}
}

View File

@ -73,13 +73,18 @@ namespace YooAsset
internal abstract void Start();
internal abstract void Update();
internal void Finish()
internal void OnFinish()
{
Progress = 1f;
_callback?.Invoke(this);
if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null);
}
internal void OnStart()
{
Status = EOperationStatus.Processing;
}
/// <summary>
/// 清空完成回调

View File

@ -4,6 +4,7 @@ namespace YooAsset
public enum EOperationStatus
{
None,
Processing,
Succeed,
Failed
}

View File

@ -67,7 +67,7 @@ namespace YooAsset
if (operation.IsDone)
{
_removeList.Add(operation);
operation.Finish();
operation.OnFinish();
}
}
@ -101,6 +101,7 @@ namespace YooAsset
public static void StartOperation(AsyncOperationBase operation)
{
_addList.Add(operation);
operation.OnStart();
operation.Start();
}
}