Table of Contents

Flow

Here we have some examples on how to build Flows

Basic

  1. Creating a new flow
  2. Queueing a tween for transform 1 to move 10 to the right
  3. Queueing a tween for transform 1 to move 10 up
  4. 1 second after the flow started adding a tween to move transform 2 to 10 right and 10 up
  5. Queuing after the previous animation a tween to move transform 2 to 10 all over
  6. Starting the flow

Note: The tweens do not need to be started because the flow will control their start

Flow flow = new Flow()
    .Queue(new Tween(2f).For(transform1).MoveX(10f))
    .Queue(new Tween(3f).For(transform1).MoveY(10f))
    .At(1f, new Tween(2f).For(transform2).MoveTo(new Vector3(10f, 10f, 0f)))
    .Queue(new Tween(3f).For(transform2).MoveTo(new Vector3(10f, 10f, 10f)))
    .Start();

Deferred

  1. Creating a new flow
  2. Queueing a tween for transform 1 to move 10 to the right
  3. Queueing a callback to create a tween for transform 1 to move 10 up. The callback is executed only after the previous animation has finished(Time index: 2 sec)
  4. Adding a callback that is executed at time index 10 sec to create a tween to move transform 2 to 10 right and 10 up
  5. Starting the flow
Flow flow = new Flow()
    .Queue(new Tween(2f).For(transform1).MoveX(10f))
    .QueueDeferred(() => new Tween(2f).For(transform1).MoveY(10f))
    .AtDeferred(10f, () => new Tween(2f).For(transform2).MoveTo(new Vector3(10f, 10f, 0f)))
    .Start();

Inception

  1. Creating a new flow as inner flow
  2. Queueing a tween for transform 1 to move 10 up
  3. Empty line
  4. Creating a new flow
  5. Queueing a tween for transform 1 to move 10 to the right
  6. Queueing the inner flow
  7. Starting the flow

Note: The inner flow does not need to be started as the flow will call its start when its time comes to be played

Flow innerFlow = new Flow()
    .Queue(new Tween(2f).For(transform).MoveY(10f));

Flow flow = new Flow() .Queue(new Tween(2f).For(transform).MoveX(10f)) .Queue(innerFlow) .Start();

Awaiters

If waiting for a task is needed in order to continue a flow, a "blocker" can be set to make the flow await till the item is finished. Available options are to await for a task, a flag callback, or custom awaiters can be created!
Task task = Task.Run(() => Task.Delay(2000));

Flow flow = new Flow() .Queue(new Tween(1f).For(transform).MoveY(10f)) .QueueAwaiter(task) .Queue(new Tween(1f).For(transform).MoveY(10f)) .Start();

Async

Same flow as before, just async.
Flow flow = await new Flow()
    .Queue(new Tween(2f).For(transform).MoveX(10f))
    .Queue(new Tween(2f).For(transform).MoveY(10f))
    .StartAsync();