Replies: 2 comments 4 replies
-
Since version 1.1.0 sequences do have a time control, and you can even manually set the elapsedTime on them.
'Group' and 'Chain' are two completely different operations. 'Grouped' tweens start at the same time and play in parallel to one another. But when you use 'Chain', the chained tween will start playing only after all tweens before it.
Yes, there is no Insert() operation in PrimeTween. It can be added very easily, although I don't see good usecases for it for now. For example, your use case can look like this: // console output:
// tween1 completed at 1.00
// tween2 completed at 2.00
// Callback at the middle of tween3 at time 3.50
// tween3 completed at 5.00
Sequence tween3WithCallbackAtMiddle = Sequence.Create(tween3)
.Group(Tween.Delay(tween3.duration / 2f, () => print($"Callback at the middle of tween3 at time {Time.time:F2}")));
Sequence.Create()
.Group(tween1) // tween1 and tween2 run in parallel
.Group(tween2)
.Chain(tween3WithCallbackAtMiddle); // tween3 starts after tween1 and tween2; the callback is invoked at the middle of tween3 Or the same as above, but simplified: Sequence.Create()
.Group(tween1)
.Group(tween2)
.Chain(tween3.Group(Tween.Delay(tween3.duration / 2f, () => print($"Callback at the middle of tween3 at time {Time.time:F2}")))); I'll think about adding Insert() in future version. Please share more examples of its usage if you have. |
Beta Was this translation helpful? Give feedback.
-
I added sequence.Insert() and sequence.InsertCallback() APIs in version 1.1.10. While it's possible to create sequences of any complexity using just Group() and Chain() operations, the new Insert() API makes it easier in some cases. For example, the Demo scene used this code previously to insert a sequence at a particular place in the float delay = 0f;
foreach (var animatable in animatables) {
Sequence sequence = animatable.Animate(toEndValue);
Sequence delayed = Tween.Delay(delay).Chain(sequence);
animateAllSequence.Group(delayed);
delay += 0.6f;
} The new version uses Insert() and makes the code much easier to write and understand: float delay = 0f;
foreach (var animatable in animatables) {
Sequence sequence = animatable.Animate(toEndValue);
animateAllSequence.Insert(delay, sequence);
delay += 0.6f;
} @YZDwork Huge thanks for the feature request! |
Beta Was this translation helpful? Give feedback.
-
Group + Delay cannot replace ChainCallback
It seems that PrimeTween's sequence does not have time point control. Although we use ChainCallback and Group(Tween.Delay()) to set callbacks at the same time point, they have different behaviors.
It seems that we need "Insert"
In your explanation, you mentioned that "Group" is the same as "Join" and we can use "Group(Tween)" instead of "Insert". However, this has raised a question. In DoTween, "Insert" does not impact the main Sequence, whereas "Join" is similar to "Append" and does affect the main Sequence. As the example shows, it's not always possible to replace "Insert" with "Group".
Sometimes, we need callbacks to run during a Chain (when the Chain's duration is 1f, the callback needs to run at 0.5f). This means that ChainCallback cannot be used in this situation. Unfortunately, Group + Delay cannot work either.
I apologize for my poor English, and I may use some inappropriate words. Please forgive me.
Here is the project:https://github.com/YZDwork/PrimeTweenDebug
Beta Was this translation helpful? Give feedback.
All reactions