Struct Leap::Unity::Animation::Tween

struct Leap.Unity.Animation.Tween

Public Functions

Tween AddInterpolator (IInterpolator interpolator)

Adds a new Interpolator to this Tween. This Interpolator will have it’s Interpolate method called every step of the Tween with the smoothed progress value. All Interpolators are recycled when the Tween itself is Recycled.

Tween OverTime (float seconds)

Specifies that this Tween should travel from begining to end over a certain number of seconds.

Tween AtRate (float unitsPerSecond)

Specifies that this Tween should travel at the given rate. This rate is measured against the FIRST interpolator added to this Tween, at the moment AtRate is called.

Tween Smooth (SmoothType type = SmoothType.Smooth)

Specifies that this Tween should the given smoothing method.

Tween Smooth (AnimationCurve curve)

Specifies that this Tween should use the given Animation curve for its smoothing. The curve should map from [0-1] to [0-1].

Tween Smooth (Func<float, float> smoothFunction)

Specifies that this Tween should use the given Function for its smoothing. The function should map from [0-1] to [0-1].

Tween OnProgress (Action<float> action)

Specifies an action to be called every step of the Tween

.

This callback happens after:

  • OnLeaveStart

  • OnLeaveEnd

  • All interpolators have been interpolated This callback happens before:

  • OnReachStart

  • OnReachEnd

Tween OnLeaveStart (Action action)

Specifies an action to be called whenever this Tween is Played forward when at the start.

Tween OnReachStart (Action action)

Specifies an action to be called whenever this Tween reaches the start.

Tween OnLeaveEnd (Action action)

Specifies an action to be called whenever this Tween is Played backwards when at the end.

Tween OnReachEnd (Action action)

Specifies an action to be called whenever this Tween reaches the end.

Tween Play ()

Starts playing this Tween. It will continue from the same position it left off on, and will continue in the same direction.

Tween Play (Direction direction)

Starts playing this Tween in a specific direction. It will condition from the same position it left off on. The direction will change even if the Tween is already playing.

Tween Play (float destinationPercent)

Starts playing this Tween towards a destination percent. Once it reaches that value, it will stop. If the destination percent is not 0 or 1, it will not trigger OnReachStart or OnReachEnd.

TweenInstance.TweenYieldInstruction Yield ()

Returns a custom yield instruction that can be yielded to in order to wait for the completion of this Tween. This will yield correctly even if the Tween is modified as it is playing.

void Pause ()

Pauses this Tween. It retains its position and direction.

void Stop ()

Stops this Tween. If it is not a persistant Tween, it will be recycled right away.

void Release ()

Forces this Tween to be recycled right away. Once this method is called, the Tween will be invalid and unable to be modified.

Properties

bool isValid { get; set; }

Returns whether or not this Tween is considered valid. A Tween can become invalid under the following conditions:

  • It was constructed with the default constructor. Only ever use Tween.Single or Tween.Persistant to create Tweens.

  • It was constructed with Tween.Single and has already finished playing. Use Tween.Persistant if you want to keep it for longer.

  • It had Release called.

bool isRunning { get; set; }

Returns whether or not the Tween is currently running.

Direction direction { get; set; }

Gets or sets whether or not this Tween is moving forwards or backwards.

float timeLeft { get; set; }

Gets how much time is left before the Tween stops.

float progress { get; set; }

Gets or sets how far along completion this Tween is. This value is a percent that ranges from 0 to 1.

Public Static Functions

static Tween Single ()

Create a single-use Tween that will auto-release itself as soon as it is finished playing.

static Tween Persistent ()

Creates a persistant Tween that will not ever auto-release itself. You must specifically call Release in order for the resources of the tween to be returned to the pool.

static Tween AfterDelay (float delay, Action onReachEnd)

Create a single-use Tween that will fire onReachEnd after the specified delay in seconds.