Show / Hide Table of Contents

struct Tween

Reference to an individual tween.

Syntax
public readonly struct Tween

Methods

View Source

ClearEase()

Clears the easing function, defaulting to linear interpolation.

Declaration
public readonly Tween ClearEase()
Returns
Type Description
Tween

This tween.

See Also
Ease(Ease)
View Source

ClearGroup()

Remove the assigned update group from this tween.

Declaration
public readonly Tween ClearGroup()
Returns
Type Description
Tween

This tween.

View Source

ClearPingPong()

Cancel PingPong.

Declaration
public readonly Tween ClearPingPong()
Returns
Type Description
Tween

This tween.

See Also
PingPong()
View Source

ClearPreserve()

Cancels Preserve, allowing the tween to be killed when it completes.

Declaration
public readonly Tween ClearPreserve()
Returns
Type Description
Tween

This tween.

See Also
Preserve()
View Source

Complete()

Complete the tween, including all loops.

Declaration
public readonly Tween Complete()
Returns
Type Description
Tween

This tween.

Remarks

When the tween is updated it will call its OnComplete callback, and will be killed if not preserved.

To complete the tween immediately, call tween.Sync().

View Source

Ease(Ease)

Set the easing function for this tween.

Declaration
public readonly Tween Ease(Ease ease)
Parameters
Type Name Description
Ease ease

A standard easing function.

Returns
Type Description
Tween

This tween.

View Source

Ease(EaseFunc)

Set the easing function for this tween.

Declaration
public readonly Tween Ease(EaseFunc easeFunc)
Parameters
Type Name Description
EaseFunc easeFunc

An easing function.

Returns
Type Description
Tween

This tween.

View Source

Ease(AnimationCurve)

Set the easing function for this tween.

Declaration
public readonly Tween Ease(AnimationCurve animationCurve)
Parameters
Type Name Description
UnityEngine.AnimationCurve animationCurve

An animation curve from (0,0) to (1,1).

Returns
Type Description
Tween

This tween.

View Source

From()

Run this tween from end to start.

Declaration
public readonly Tween From()
Returns
Type Description
Tween

This tween.

View Source

GoTo(Single)

Set the interal time of a tween.

Declaration
public readonly Tween GoTo(float elapsed)
Parameters
Type Name Description
System.Single elapsed

The time to set the tween to. 0 will rewind the tween to the start, and passing the tween's duration will fast-forward to the end.

Returns
Type Description
Tween

This tween.

View Source

IsActive()

Check if this tween is incomplete.

Declaration
public readonly bool IsActive()
Returns
Type Description
System.Boolean

true if the tween has not yet completed or been killed; false if the tween has completed or been killed.

Remarks

A tween is considered active until it's complete or killed. Pausing a tween does not decativate it.

View Source

IsAlive()

Check if this tween exists.

Declaration
public readonly bool IsAlive()
Returns
Type Description
System.Boolean

true if the tween exists; false if the tween not been set or has been killed.

Remarks

Tweens will are alive from creation until they complete or are killed. You can prevent automatic killing of complete tweens by preserving them.

See Also
Kill(Boolean)
Preserve()
View Source

IsComplete()

Check if the tween has ended.

Declaration
public readonly bool IsComplete()
Returns
Type Description
System.Boolean

true if tween is complete; false if tween is not complete.

Remarks

This is useful for tweens that are preserved, as any other tween will be killed upon completion.

View Source

IsPaused()

Check if the tween is paused.

Declaration
public readonly bool IsPaused()
Returns
Type Description
System.Boolean

true if the tween is paused; false if the tween is not paused.

See Also
Pause()
Resume()
View Source

Kill(Boolean)

Deactivate this tween and delete it next time it's updated.

Declaration
public readonly void Kill(bool complete = false)
Parameters
Type Name Description
System.Boolean complete

Also complete this tween, updating its value to its end value and calling its OnComplete callback.

Remarks

This marks a tween for deletion, but it will not be deleted until its next update. This means that callbacks such as OnKill will not be triggered immediately. If you need callbacks to run immediately, then use KillSync instead.

See Also
KillSync(Boolean)
View Source

KillSync(Boolean)

Like Kill but updates the tween immediately.

Declaration
public readonly void KillSync(bool complete = false)
Parameters
Type Name Description
System.Boolean complete

Also complete this tween, updating its value to its end value and calling its OnComplete callback.

Remarks

This is equivalent to tween.Kill(); tween.Sync() but will not log a warning if the tween has previously been killed.

See Also
Kill(Boolean)
View Source

Lerp<T>(LerpFunc<T>)

Override the default lerp function for this tween.

Declaration
public readonly Tween Lerp<T>(LerpFunc<T> lerp)
Parameters
Type Name Description
LerpFunc<T> lerp

The lerp function for this tween.

Returns
Type Description
Tween

This tween.

Type Parameters
Name Description
T

The type of the value being tweened.

See Also
Punch(Int32, Single, Single)
View Source

Loop(Int32)

Set the number of times this tween should loop.

Declaration
public readonly Tween Loop(int count)
Parameters
Type Name Description
System.Int32 count

The number of times this tween should loop, cannot be negative.

Setting to 1 will stop the tween from looping, setting to 0 will kill the tween without completing it.

Returns
Type Description
Tween

This tween.

View Source

LoopForever()

Set the tween to loop endlessly.

Declaration
public readonly Tween LoopForever()
Returns
Type Description
Tween

This tween.

View Source

ManualUpdate(Single)

Update this tween is isolation, applying its changes immediately.

Declaration
public readonly void ManualUpdate(float deltaTime)
Parameters
Type Name Description
System.Single deltaTime

The amount of time to progress tweens by.

Remarks

Typically used in combination with SetManualUpdate.

See Also
SetManualUpdate()
View Source

OnComplete(Action)

Register a callback to be invoked when this tween reaches the end value.

Declaration
public readonly Tween OnComplete(Action onComplete)
Parameters
Type Name Description
System.Action onComplete
Returns
Type Description
Tween

This tween.

View Source

OnKill(Action)

Register a callback to be invoked when this tween dies, either due to completion or because it was killed.

Declaration
public readonly Tween OnKill(Action onKill)
Parameters
Type Name Description
System.Action onKill
Returns
Type Description
Tween

This tween.

See Also
Kill(Boolean)
View Source

OnLoop(Action)

Register a callback to be invoked every time this tween loops.

Declaration
public readonly Tween OnLoop(Action onComplete)
Parameters
Type Name Description
System.Action onComplete
Returns
Type Description
Tween

This tween.

See Also
Loop(Int32)
View Source

OnUpdate(Action)

Register a callback to be invoked every time this tween progresses.

Declaration
public readonly Tween OnUpdate(Action handler)
Parameters
Type Name Description
System.Action handler
Returns
Type Description
Tween

This tween.

View Source

Pause()

Pause the tween.

Declaration
public readonly Tween Pause()
Returns
Type Description
Tween

This tween.

See Also
Resume()
View Source

PingPong()

Set the tween to reverse at the start of each loop.

Declaration
public readonly Tween PingPong()
Returns
Type Description
Tween

This tween.

See Also
Loop(Int32)
ClearPingPong()
Reverse()
View Source

Preserve()

Prevent tween from being automatically killed when it completes.

Declaration
public readonly Tween Preserve()
Returns
Type Description
Tween

This tween.

Remarks

Use this to create a replayable tween.

See Also
ClearPreserve()
View Source

Punch(Int32, Single, Single)

Set the ease to oscillate and fade out.

Declaration
public readonly Tween Punch(int oscillationCount, float amplitudeDecay, float frequencyDecay)
Parameters
Type Name Description
System.Int32 oscillationCount

The number of times the value will oscillate (half the period).

A negative value will move the value away from the target on its first oscillation.

System.Single amplitudeDecay

Rate at which the amplitude of the wave decreases.

  • Higher values cause a more vigorous initial shake.
  • A value of zero will cause amplitude to stay constant.
  • Values below zero cause the amplitude to increase over time, tending towards infinity.
System.Single frequencyDecay

Rate at which the frequency of the wave decreases.

Higher values cause a more vigorous initial shake. Values below zero cause the shake to increase in speed over time.

Returns
Type Description
Tween

This tween.

View Source

RemoveOnComplete(Action)

Remove OnComplete callback.

Declaration
public readonly Tween RemoveOnComplete(Action onComplete)
Parameters
Type Name Description
System.Action onComplete
Returns
Type Description
Tween

This tween.

See Also
OnComplete(Action)
View Source

RemoveOnKill(Action)

Remove OnKill callback.

Declaration
public readonly Tween RemoveOnKill(Action onKill)
Parameters
Type Name Description
System.Action onKill
Returns
Type Description
Tween

This tween.

See Also
OnKill(Action)
View Source

RemoveOnLoop(Action)

Remove OnLoop callback.

Declaration
public readonly Tween RemoveOnLoop(Action onComplete)
Parameters
Type Name Description
System.Action onComplete
Returns
Type Description
Tween

This tween.

See Also
OnLoop(Action)
View Source

RemoveOnUpdate(Action)

Remove OnUpdate callback.

Declaration
public readonly Tween RemoveOnUpdate(Action handler)
Parameters
Type Name Description
System.Action handler
Returns
Type Description
Tween

This tween.

See Also
OnUpdate(Action)
View Source

Restart()

Restart the tween and unpause it.

Equivalent to tween.Rewind().Resume()

Declaration
public readonly Tween Restart()
Returns
Type Description
Tween
See Also
Rewind()
Resume()
View Source

Resume()

Unpause the tween.

Declaration
public readonly Tween Resume()
Returns
Type Description
Tween

This tween.

See Also
Pause()
View Source

Reverse()

Reverse the direction of this tween.

Declaration
public readonly Tween Reverse()
Returns
Type Description
Tween

This tween.

View Source

Rewind()

Return the tween to the start.

Equivalent to GoTo(0).

Declaration
public readonly Tween Rewind()
Returns
Type Description
Tween

This tween.

See Also
GoTo(Single)
View Source

SetFixedUpdate()

Set tween to update on FixedUpdate.

Declaration
public readonly Tween SetFixedUpdate()
Returns
Type Description
Tween

This tween.

View Source

SetGroup<TGroup>()

Change the tween's update group.

Declaration
public readonly Tween SetGroup<TGroup>()
    where TGroup : struct
Returns
Type Description
Tween

This tween.

Type Parameters
Name Description
TGroup

An empty struct that is used as an identifier for your custom group.

Remarks

Tweens default to the Update group, but custom groups can be added.

This group can be updated on a custom update cycle using Peachy.Run.

View Source

SetLateUpdate()

Set tween to update on LateUpdate.

Declaration
public readonly Tween SetLateUpdate()
Returns
Type Description
Tween

This tween.

View Source

SetManualUpdate()

Disable automatic update of this tween.

Declaration
public readonly Tween SetManualUpdate()
Returns
Type Description
Tween

This tween.

Remarks

This is an alias of ClearGroup.

View Source

SetTarget<T>(T)

Set the associated target of a Tween for killing by target.

Declaration
public readonly Tween SetTarget<T>(T target)
    where T : class
Parameters
Type Name Description
T target

Any instance of a reference type to become the target of this tween.

Returns
Type Description
Tween

This tween.

Type Parameters
Name Description
T
Remarks

This will replace any previously set target.

This method is called by provided extension methods (e.g. TweenPosition), and should be called by any custom extension methods.

This does not change which object the Tween is currently acting on, its purpose is to link this tween to an object so that it will be killed when the target object is passed to KillAllWithTarget.

See Also
KillAllWithTarget(Object, Boolean)
View Source

SetUnscaledFixedUpdate()

Set tween to update on FixedUpdate using unscaled time.

Declaration
public readonly Tween SetUnscaledFixedUpdate()
Returns
Type Description
Tween

This tween.

View Source

SetUnscaledLateUpdate()

Set tween to update on LateUpdate using unscaled time.

Declaration
public readonly Tween SetUnscaledLateUpdate()
Returns
Type Description
Tween

This tween.

View Source

SetUnscaledUpdate()

Set tween to update on Update using unscaled time.

Declaration
public readonly Tween SetUnscaledUpdate()
Returns
Type Description
Tween

This tween.

View Source

SetUpdate()

Set tween to update on Update.

Declaration
public readonly Tween SetUpdate()
Returns
Type Description
Tween

This tween.

Remarks

This is the default update group for new tweens.

View Source

Shake(Int32, Single, Single)

Set the lerp function to shake.

Supported by Vector3 tweens only.

Declaration
public readonly Tween Shake(int oscillationCount, float decay, float randomness)
Parameters
Type Name Description
System.Int32 oscillationCount

Number of oscillations per axis.

System.Single decay

Rate at which amplitude and frequency decrease over time.

System.Single randomness

Maximum percentage change randomly applied to amplitude and frequency per axis.

Returns
Type Description
Tween

This tween.

Remarks

This overrides the default tween function to shake its values. This creates a lerp function that performs the Punch ease on each dimension of the tweened value.

See Also
Punch(Int32, Single, Single)
View Source

Shake(Int32, Single, Single, Single, Single)

Set the lerp function to shake.

Supported by Vector3 tweens only.

Declaration
public readonly Tween Shake(int oscillationCount, float amplitudeDecay, float frequencyDecay, float amplitudeRandomness, float frequencyRandomness)
Parameters
Type Name Description
System.Int32 oscillationCount

Number of oscillations per axis.

System.Single amplitudeDecay

Rate at which amplitude decreases over time.

System.Single frequencyDecay

Rate at which frequency decreases over time.

System.Single amplitudeRandomness

Maximum percentage change randomly applied to amplitude per axis.

System.Single frequencyRandomness

Maximum percentage change randomly applied to frequency per axis.

Returns
Type Description
Tween

This tween.

Remarks

This overrides the default tween function to shake its values. This creates a lerp function that performs the Punch ease on each dimension of the tweened value.

See Also
Punch(Int32, Single, Single)
View Source

Shake2D(Int32, Single, Single)

Set the lerp function to shake.

Supported by Vector2 tweens only.

Declaration
public readonly Tween Shake2D(int oscillationCount, float decay, float randomness)
Parameters
Type Name Description
System.Int32 oscillationCount

Number of oscillations per axis.

System.Single decay

Rate at which amplitude and frequency decrease over time.

System.Single randomness

Maximum percentage change randomly applied to amplitude and frequency per axis.

Returns
Type Description
Tween

This tween.

Remarks

This overrides the default tween function to shake its values. This creates a lerp function that performs the Punch ease on each dimension of the tweened value.

See Also
Punch(Int32, Single, Single)
View Source

Shake2D(Int32, Single, Single, Single, Single)

Set the lerp function to shake.

Supported by Vector2 tweens only.

Declaration
public readonly Tween Shake2D(int oscillationCount, float amplitudeDecay, float frequencyDecay, float amplitudeRandomness, float frequencyRandomness)
Parameters
Type Name Description
System.Int32 oscillationCount

Number of oscillations per axis.

System.Single amplitudeDecay

Rate at which amplitude decreases over time.

System.Single frequencyDecay

Rate at which frequency decreases over time.

System.Single amplitudeRandomness

Maximum percentage change randomly applied to amplitude per axis.

System.Single frequencyRandomness

Maximum percentage change randomly applied to frequency per axis.

Returns
Type Description
Tween

This tween.

Remarks

This overrides the default tween function to shake its values. This creates a lerp function that performs the Punch ease on each dimension of the tweened value.

See Also
Punch(Int32, Single, Single)
View Source

ShortestAngle()

Treat the value of the tween as a rotation in degrees, and rotate through the shorest angle to the end value.

Only compatible with float tweens.

Declaration
public readonly Tween ShortestAngle()
Returns
Type Description
Tween

This tween.

View Source

Slerp()

Rotate the vector tween value around the origin, instead of taking the shortest path. through the shorest angle to the end value.

Only compatible with Vector2 and Vector3 tweens.

Declaration
public readonly Tween Slerp()
Returns
Type Description
Tween

This tween.

View Source

StopLoop()

Stop the tween from looping.

Declaration
public readonly Tween StopLoop()
Returns
Type Description
Tween

This tween.

View Source

Sync()

Immediately apply any changes to this tween.

Declaration
public readonly Tween Sync()
Returns
Type Description
Tween

This tween.

Remarks

This will trigger callbacks.

Equivalent to tween.SetManualUpdate(0).

See Also
KillSync(Boolean)
SetManualUpdate()
View Source

TryGetTarget(out Object)

Get the associated target of a Tween.

Declaration
public readonly bool TryGetTarget(out object target)
Parameters
Type Name Description
System.Object target

The previously set target.

Returns
Type Description
System.Boolean

true if a target has been set; false if no target has been set.

See Also
SetTarget<T>(T)
  • View Source
On this page
Back to top Generated by DocFX