How to differentiate between tween completion and tween stop? #190
-
|
I have the following (simplified example code): public static async UniTask AnimateOut(this VisualElement el) {
tween = Tween.VisualElementOpacity(...);
await tween;
// I only want this to run if the tween completes fully.
el.style.display = DisplayStyle.None;
}If the element fully animates out, I want to run some more code. If it's stopped beforehand (for instance, if somewhere else, a similar AnimateIn function is called) I don't want the code to run. I haven't found an elegant way to differentiate why the await finished waiting. There's no OnStop callback. There's no support for a CancellationToken. I can't check the progress variable because that only works if the tween I'm guessing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hey, OnComplete seems like a perfect match for your use case. It's okay to combine it with async/await. You're right, OnComplete is invoked only when an animation completes to the end or Complete() is called manually. |
Beta Was this translation helpful? Give feedback.
Hey, OnComplete seems like a perfect match for your use case. It's okay to combine it with async/await.
You're right, OnComplete is invoked only when an animation completes to the end or Complete() is called manually.