From f3e3ba8864bcba8968eaec27e7aae8ad4723675b Mon Sep 17 00:00:00 2001 From: neuecc Date: Sat, 23 May 2020 02:53:48 +0900 Subject: [PATCH] fix DOTweenExt's TweenCancelBehaviour.CancelAwait --- .../Runtime/External/DoTweenAsyncExtensions.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs index be36407..1955f7a 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs @@ -86,7 +86,8 @@ namespace Cysharp.Threading.Tasks sealed class TweenConfiguredSource : IUniTaskSource, IPromisePoolItem { static readonly PromisePool pool = new PromisePool(); - static Action CancellationCallbackDelegate = CancellationCallback; + static readonly Action CancellationCallbackDelegate = CancellationCallback; + static readonly TweenCallback EmptyTweenCallback = () => { }; Tween tween; TweenCancelBehaviour cancelBehaviour; @@ -138,14 +139,7 @@ namespace Cysharp.Threading.Tasks cancellationTokenRegistration.Dispose(); if (canceled) { - if (cancelBehaviour == TweenCancelBehaviour.CancelAwait) - { - // already called TrySetCanceled, do nothing. - } - else - { - core.TrySetCanceled(cancellationToken); - } + core.TrySetCanceled(cancellationToken); } else { @@ -189,7 +183,7 @@ namespace Cysharp.Threading.Tasks self.tween.Complete(true); break; case TweenCancelBehaviour.CancelAwait: - self.canceled = true; + self.tween.onKill = EmptyTweenCallback; // replace to empty(avoid callback after Caceled(instance is returned to pool.) self.core.TrySetCanceled(self.cancellationToken); break; }