From f783fd42bcc43a05a71fcb9925a2d2f2abf696ce Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 11 Aug 2023 16:20:38 +0800 Subject: [PATCH] update operation system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Operation状态增加Processing处理中状态 --- .../AssetSystem/Handles/OperationHandleBase.cs | 14 +++++++++----- .../Runtime/OperationSystem/AsyncOperationBase.cs | 7 ++++++- .../Runtime/OperationSystem/EOperationStatus.cs | 1 + .../Runtime/OperationSystem/OperationSystem.cs | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs index 2dde697..737e60e 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs @@ -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; } } diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs index 0a254ff..6f46416 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs @@ -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; + } /// /// 清空完成回调 diff --git a/Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs b/Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs index 5cecac5..cedb72e 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/EOperationStatus.cs @@ -4,6 +4,7 @@ namespace YooAsset public enum EOperationStatus { None, + Processing, Succeed, Failed } diff --git a/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs index e0d4fe2..0c12a54 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs @@ -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(); } }