mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-21 15:20:24 +00:00
fix DOTweenExt's TweenCancelBehaviour.CancelAwait
This commit is contained in:
@@ -86,7 +86,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
sealed class TweenConfiguredSource : IUniTaskSource, IPromisePoolItem
|
sealed class TweenConfiguredSource : IUniTaskSource, IPromisePoolItem
|
||||||
{
|
{
|
||||||
static readonly PromisePool<TweenConfiguredSource> pool = new PromisePool<TweenConfiguredSource>();
|
static readonly PromisePool<TweenConfiguredSource> pool = new PromisePool<TweenConfiguredSource>();
|
||||||
static Action<object> CancellationCallbackDelegate = CancellationCallback;
|
static readonly Action<object> CancellationCallbackDelegate = CancellationCallback;
|
||||||
|
static readonly TweenCallback EmptyTweenCallback = () => { };
|
||||||
|
|
||||||
Tween tween;
|
Tween tween;
|
||||||
TweenCancelBehaviour cancelBehaviour;
|
TweenCancelBehaviour cancelBehaviour;
|
||||||
@@ -138,14 +139,7 @@ namespace Cysharp.Threading.Tasks
|
|||||||
cancellationTokenRegistration.Dispose();
|
cancellationTokenRegistration.Dispose();
|
||||||
if (canceled)
|
if (canceled)
|
||||||
{
|
{
|
||||||
if (cancelBehaviour == TweenCancelBehaviour.CancelAwait)
|
core.TrySetCanceled(cancellationToken);
|
||||||
{
|
|
||||||
// already called TrySetCanceled, do nothing.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
core.TrySetCanceled(cancellationToken);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -189,7 +183,7 @@ namespace Cysharp.Threading.Tasks
|
|||||||
self.tween.Complete(true);
|
self.tween.Complete(true);
|
||||||
break;
|
break;
|
||||||
case TweenCancelBehaviour.CancelAwait:
|
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);
|
self.core.TrySetCanceled(self.cancellationToken);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user