Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Sep 21, 2023
1 parent be8dbe8 commit 3ed28e5
Showing 1 changed file with 11 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,30 +251,7 @@ public static IUniTaskSource Create(Tween tween, TweenCancelBehaviour cancelBeha
source.tween.Complete(true);
break;
case TweenCancelBehaviour.CancelAwait:
// restore to original callback
switch (callbackType)
{
case CallbackType.Kill:
tween.onKill = source.originalCompleteAction;
break;
case CallbackType.Complete:
tween.onComplete = source.originalCompleteAction;
break;
case CallbackType.Pause:
tween.onPause = source.originalCompleteAction;
break;
case CallbackType.Play:
tween.onPlay = source.originalCompleteAction;
break;
case CallbackType.Rewind:
tween.onRewind = source.originalCompleteAction;
break;
case CallbackType.StepComplete:
tween.onStepComplete = source.originalCompleteAction;
break;
default:
break;
}
source.RestoreOriginalCallback();
source.core.TrySetCanceled(source.cancellationToken);
break;
}
Expand Down Expand Up @@ -379,6 +356,16 @@ bool TryReturn()
core.Reset();
cancellationRegistration.Dispose();

RestoreOriginalCallback();

tween = default;
cancellationToken = default;
originalCompleteAction = default;
return pool.TryPush(this);
}

void RestoreOriginalCallback()
{
switch (callbackType)
{
case CallbackType.Kill:
Expand All @@ -402,11 +389,6 @@ bool TryReturn()
default:
break;
}

tween = default;
cancellationToken = default;
originalCompleteAction = default;
return pool.TryPush(this);
}
}
}
Expand Down

0 comments on commit 3ed28e5

Please sign in to comment.