How Sequences work
mainA Sequence is a container for grouping tweens, callbacks, and other sequences. It allows you to orchestrate complex animations that can overlap, run sequentially, or run in parallel.
Sequence Composition Methods:
Insert(float atTime, Tween/Sequence animation): Places an animation at a specific time, overlapping with existing animations. This may increase the total sequence duration.Chain(Tween/Sequence animation): Places an animation after all previously added animations. Chained animations run sequentially.Group(Tween/Sequence animation): Groups an animation with the preceding animation in the sequence. Grouped animations start at the same time and run in parallel.
To apply cycles to a Sequence, use Sequence.Create(cycles: numCycles, cycleMode: CycleMode.Yoyo).
Sequence.Create(cycles: 10, CycleMode.Yoyo)
// PositionX and Scale tweens are 'grouped', so they will run in parallel
.Group(Tween.PositionX(transform, endValue: 10f, duration: 1.5f))
.Group(Tween.Scale(transform, endValue: 2f, duration: 0.5f, startDelay: 1))
// Rotation tween is 'chained' so it will start when both previous tweens are finished (after 1.5 seconds)
.Chain(Tween.Rotation(transform, endValue: new Vector3(0f, 0f, 45f), duration: 1f))
.ChainDelay(1)
.ChainCallback(() => Debug.Log("Sequence cycle completed"))
// Insert color animation at time of '0.5' seconds
// Inserted animations overlap with other animations in the sequence
.Insert(atTime: 0.5f, Tween.Color(image, Color.red, duration: 0.5f));