struct Tween
Reference to an individual tween.
Syntax
public readonly struct Tween
Methods
View SourceClearEase()
Clears the easing function, defaulting to linear interpolation.
Declaration
public readonly Tween ClearEase()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourceClearGroup()
Remove the assigned update group from this tween.
Declaration
public readonly Tween ClearGroup()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
ClearPingPong()
Cancel PingPong.
Declaration
public readonly Tween ClearPingPong()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourceClearPreserve()
Cancels Preserve, allowing the tween to be killed when it completes.
Declaration
public readonly Tween ClearPreserve()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourceComplete()
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().
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. |
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. |
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. |
From()
Run this tween from end to start.
Declaration
public readonly Tween From()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
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. |
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
IsActive()
Check if this tween is incomplete.
Declaration
public readonly bool IsActive()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remarks
A tween is considered active until it's complete or killed. Pausing a tween does not decativate it.
IsAlive()
Check if this tween exists.
Declaration
public readonly bool IsAlive()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
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
View SourceIsComplete()
Check if the tween has ended.
Declaration
public readonly bool IsComplete()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remarks
This is useful for tweens that are preserved, as any other tween will be killed upon completion.
IsPaused()
Check if the tween is paused.
Declaration
public readonly bool IsPaused()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
See Also
View SourceKill(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 |
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
View SourceKillSync(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 |
Remarks
This is equivalent to tween.Kill(); tween.Sync() but will not log a
warning if the tween has previously been killed.
See Also
View SourceLerp<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
View SourceLoop(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 |
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
LoopForever()
Set the tween to loop endlessly.
Declaration
public readonly Tween LoopForever()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
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
View SourceOnComplete(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. |
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
View SourceOnLoop(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
View SourceOnUpdate(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. |
Pause()
Pause the tween.
Declaration
public readonly Tween Pause()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourcePingPong()
Declaration
public readonly Tween PingPong()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourcePreserve()
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
View SourcePunch(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.
|
| 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. |
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
View SourceRemoveOnKill(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
View SourceRemoveOnLoop(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
View SourceRemoveOnUpdate(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
View SourceRestart()
Restart the tween and unpause it.
Equivalent to tween.Rewind().Resume()
Declaration
public readonly Tween Restart()
Returns
| Type | Description |
|---|---|
| Tween |
See Also
View SourceResume()
Unpause the tween.
Declaration
public readonly Tween Resume()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourceReverse()
Reverse the direction of this tween.
Declaration
public readonly Tween Reverse()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
Rewind()
Return the tween to the start.
Equivalent to GoTo(0).
Declaration
public readonly Tween Rewind()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
See Also
View SourceSetFixedUpdate()
Set tween to update on FixedUpdate.
Declaration
public readonly Tween SetFixedUpdate()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
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.
SetLateUpdate()
Set tween to update on LateUpdate.
Declaration
public readonly Tween SetLateUpdate()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
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.
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
View SourceSetUnscaledFixedUpdate()
Set tween to update on FixedUpdate using unscaled time.
Declaration
public readonly Tween SetUnscaledFixedUpdate()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
SetUnscaledLateUpdate()
Set tween to update on LateUpdate using unscaled time.
Declaration
public readonly Tween SetUnscaledLateUpdate()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
SetUnscaledUpdate()
Set tween to update on Update using unscaled time.
Declaration
public readonly Tween SetUnscaledUpdate()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
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.
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
View SourceShake(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
View SourceShake2D(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
View SourceShake2D(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
View SourceShortestAngle()
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. |
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. |
StopLoop()
Stop the tween from looping.
Declaration
public readonly Tween StopLoop()
Returns
| Type | Description |
|---|---|
| Tween | This tween. |
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
View SourceTryGetTarget(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 |
|