DOTween cancellation token not immediate
See original GitHub issueI’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:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Another workaround; call
tween.onUpdate
just after cancel. (quite cumbersome though)Looking forward to neat implementation. 👀