diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs index 1241982..19bff32 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/InstantiateOperation.cs @@ -62,7 +62,7 @@ namespace YooAsset return; } - if(_setPositionRotation) + if (_setPositionRotation) { if (_parent == null) Result = Object.Instantiate(_handle.AssetObject as GameObject, _position, _rotation); @@ -81,5 +81,14 @@ namespace YooAsset Status = EOperationStatus.Succeed; } } + public override void Cancel() + { + if (IsDone == false) + { + _steps = ESteps.Done; + Status = EOperationStatus.Failed; + Error = $"User cancelled !"; + } + } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs index f2cbed6..0730ed8 100644 --- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs +++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs @@ -81,6 +81,14 @@ namespace YooAsset _taskCompletionSource.TrySetResult(null); } + /// + /// 取消异步操作 + /// + public virtual void Cancel() + { + throw new NotImplementedException("Can not cancel operation !"); + } + #region 异步编程相关 bool IEnumerator.MoveNext() {