question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOTween cancellation token not immediate

See original GitHub issue

I’ve noticed that whenever I wanted to cancel a tween immediately, I’d have to wait until the end of the frame for the tween to stop. Is it possible to kill the tween immediately, so my cancel logic can become synchronous instead of asynchronous?

Ex. (What I’m doing right now)

cancelTween?.Cancel();
cancelTween?.Dispose();
cancelTween = new CancellationTokenSource();
await UniTask.WaitForEndOfFrame(this); // Tween is actually not cancelled yet!
transform.SetParent(canvas.transform, true); // Tween has been cancelled, now we can do what we want with the tweened object

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
neuecccommented, Jul 21, 2022

Because of Performance (Register has allocations), it is not immediate. However, I understand the needs, I will try to find a way to implement it efficiently.

4reactions
yellowishercommented, Jul 26, 2022

Another workaround; call tween.onUpdate just after cancel. (quite cumbersome though)

cancelTween.Cancel();
tween.onUpdate(); // Instead of WaitForEndOfFrame
transform.position = Vector3.zero;

Looking forward to neat implementation. 👀

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Immediate Task Cancellation
I have a question regarding task cancelling using cancellationToken and cancellationTokenSource: The usual way is as follows: var cts = new ...
Read more >
Async in Unity (better or worse than coroutines?)
This works by declaring a Cancellation Token Source, which can be used to provide a cancellation token to the task when it's run....
Read more >
com.cysharp.unitask
DOTween support's default behaviour( await , WithCancellation , ToUniTask ) awaits tween is killed. It works on both Complete(true/false) and Kill(true/false).
Read more >
Unity async / await: Coroutine's Hot Sister : r/gamedev
A cancellation token is really nothing more than a flag, and the code running in the task must specifically check that flag and...
Read more >
UniTask v2 — Zero Allocation async/await for Unity, with ...
Progress callbacks, PlayerLoop to run, and It is now a method that can pass a CancellationToken. In addition, support for DOTween and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found