My animation is basicly shows the valid words user found in order.
My method does this:
if (showWordsSequence.IsPlaying())
{
showWordsSequence.Append(group.transform.DOScale(1f, 0.6f));
showWordsSequence.AppendInterval(0.2f);
showWordsSequence.Append(group.transform.DOScale(0f, 0.6f));
showWordsSequence.Append(DOVirtual.DelayedCall(0.2f,() => Destroy(group.gameObject)));
}
else
{
showWordsSequence = DOTween.Sequence();
showWordsSequence.Append(group.transform.DOScale(1f, 0.6f));
showWordsSequence.AppendInterval(0.2f);
showWordsSequence.Append(group.transform.DOScale(0f, 0.6f));
showWordsSequence.Append(DOVirtual.DelayedCall(0.2f, () => Destroy(group.gameObject)));
}
showWordsSequence is a global Sequence variable. When I call this method 3 times in a for loop (in the same frame) it works. But, when sequence starts playing and after 1-2 seconds, i call this method again it does not append the animation. Is there any workaround on this?
Taken from documentation:
http://dotween.demigiant.com/documentation.php
Sadly, the only workaround I know is to create whole sequence beforehand. Other idea is to create second, paused, sequence, append to it and have OnComplete callback starting playback of the new one (if it ain't empty).
Thanks for your reply!
Wish we could just append to ongoing sequences ^^ I had seen the thing about virtual methods but it always works for me i don't know why.
I might actually rethink about appending to ongoing Sequences, but will take me a while.
Virtual methods do return a Tween object, so in theory they "can" be added to Sequences. But since they're somehow different, I don't recommend doing that. In short, I'm not taking any responsibility for virtual methods inside Sequences :D
That would be so great actually.
Yes, you are right. I've rewritten the virtual methods, they are acting kinda funny. Thou shalt not trust virtual methods!!!
Hi. In case anyone else is googling it in 2019. This is the best workaround for this situation.
//'Global' queue for animations. First one ( .Peek() ) is playing, others are waiting in queue
public Queue<Sequence> AnimationQueue = new Queue<Sequence>();
//Entry point
public void PlayQueuedAnimation()
{
//Create paused sequence
var seq = DG.Tweening.DOTween.Sequence();
seq.Pause();
//Append everything you want
seq.Append(targetTransform.DOLocalMoveX(5f, 1f));
//...
//Add to queue
AnimationQueue.Enqueue(seq);
//Check if this animation is first in queue
if (AnimationQueue.Count == 1)
{
AnimationQueue.Peek().Play();
}
//Set callback
seq.OnComplete(OnComplete);
}
//Callback
private void OnComplete()
{
//remove animation that was completed
AnimationQueue.Dequeue();
//if there's animations in queue left
if (AnimationQueue.Count > 0)
{
//play next
AnimationQueue.Peek().Play();
}
}
Most helpful comment
Hi. In case anyone else is googling it in 2019. This is the best workaround for this situation.