mirror of https://github.com/Cysharp/UniTask
Compare commits
5 Commits
fe1d15b4a7
...
35f2fca99a
Author | SHA1 | Date |
---|---|---|
|
35f2fca99a | |
|
87c04a29fa | |
|
952e113011 | |
|
03ef341096 | |
|
5e266f5538 |
|
@ -99,6 +99,23 @@ namespace Cysharp.Threading.Tasks
|
|||
return new UniTask(TweenConfiguredSource.Create(tween, tweenCancelBehaviour, cancellationToken, CallbackType.StepComplete, out var token), token);
|
||||
}
|
||||
|
||||
public static async UniTask AwaitWithCancellation(this Tween tween, CancellationToken cancellationToken)
|
||||
{
|
||||
Error.ThrowArgumentNullException(tween, nameof(tween));
|
||||
|
||||
if (!tween.IsActive()) await UniTask.CompletedTask;
|
||||
|
||||
using var registration = cancellationToken.Register(() =>
|
||||
{
|
||||
if (tween.IsActive())
|
||||
{
|
||||
tween.Kill();
|
||||
}
|
||||
});
|
||||
|
||||
await tween.ToUniTask(TweenCancelBehaviour.KillAndCancelAwait, cancellationToken);
|
||||
}
|
||||
|
||||
public struct TweenAwaiter : ICriticalNotifyCompletion
|
||||
{
|
||||
readonly Tween tween;
|
||||
|
|
Loading…
Reference in New Issue