Class TransformAnimator
Transform Animation for animating a unity transform
Inheritance
Implements
Namespace: AnimationHelpers
Assembly: cs.temp.dll.dll
Syntax
public class TransformAnimator : MonoBehaviour, IDisposable
Properties
CurrentCoroutine
The current coroutine useful when used in an other coroutine to wait till the animation is finished with
yield return animation.CurrentCoroutine
Declaration
public Coroutine CurrentCoroutine { get; }
Property Value
Type | Description |
---|---|
Coroutine |
IsRunning
True if the animation is running
Declaration
public bool IsRunning { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Create(Transform)
Create a new TransformAnimator
Declaration
public static TransformAnimator Create(Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | the transform to animate |
Returns
Type | Description |
---|---|
TransformAnimator | a new TransformAnimator |
Dispose()
Does the same as stop. Does not need to be called for cleanup will be called after the execution has finished.
Declaration
public void Dispose()
Do(Action)
Do a Action (will be executed one time)
Declaration
public TransformAnimator Do(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The action to execute |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Execute()
Execute all added animations and sequences
Declaration
public TransformAnimator Execute()
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalMove(Vector3, Single, Func<Single, Single>)
Add a Move animation uses the local position. Animate form current local position (before the start of the hole animation) till pos
Declaration
public TransformAnimator LocalMove(Vector3 pos, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | pos | The local position to move to |
System.Single | duration | The duration of the animation in seconds |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalMove(Vector3, Vector3, Single, Func<Single, Single>)
Add a Move animation uses the local position.
Declaration
public TransformAnimator LocalMove(Vector3 startpos, Vector3 endPos, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | startpos | The local start position to move to |
Vector3 | endPos | The local end position to move to |
System.Single | duration | The duration of the animation in seconds |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalMovePath(IList<Vector3>, IList<Single>, Func<Single, Single>)
Move the transform along a path. The start point will be the current position of the Transform (Do not include this position in the path IEnumerable) Example how the different parameters will be applied
transform.postion path[0]
o ------------------durations[0]-----------►•
│
durations[1]
│
▼
•◄------------------durations[2]------------•
path[2] path[1]
Declaration
public TransformAnimator LocalMovePath(IList<Vector3> path, IList<float> durations, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
IList<Vector3> | path | The path points without the current transform position |
IList<System.Single> | durations | The durations for each path point |
Func<System.Single, System.Single> | easeFunction | The ease function will be applied for each transition form point to point and not for the hole animation |
Returns
Type | Description |
---|---|
TransformAnimator | The TramsformAnimator |
LocalMovePath(IList<Vector3>, Single, Func<Single, Single>)
Move the transform along a path uses the local position. The start point will be the current position of the Transform (Do not include this position in the path IEnumerable)
Declaration
public TransformAnimator LocalMovePath(IList<Vector3> path, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
IList<Vector3> | path | The path points without the current transform position |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease function will be applied for each transition form point to point and not for the hole animation |
Returns
Type | Description |
---|---|
TransformAnimator | The TramsformAnimator |
LocalMovePath(Single, Func<Single, Single>, Vector3[])
Move the transform along a path. The start point will be the current position of the Transform (Do not include this position in the path IEnumerable)
Declaration
public TransformAnimator LocalMovePath(float duration, Func<float, float> easeFunction = null, params Vector3[] path)
Parameters
Type | Name | Description |
---|---|---|
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease function will be applied for each transition form point to point and not for the hole animation |
Vector3[] | path | The path points without the current transform position |
Returns
Type | Description |
---|---|
TransformAnimator | The TramsformAnimator |
LocalMoveWithSpeed(Vector3, Single, Func<Single, Single>)
Add a Move animation uses the local position and uses speed and not a duration. Animate form current local position (before the start of the hole animation) till pos
Declaration
public TransformAnimator LocalMoveWithSpeed(Vector3 pos, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | pos | The local position to move to |
System.Single | speed | The speed of the animation. When the distance is 1 unity unit with the speed 1 it will take 1 seconds to animate. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalMoveWithSpeed(Vector3, Vector3, Single, Func<Single, Single>)
Add a Move animation uses the local position and uses speed and not a duration.
Declaration
public TransformAnimator LocalMoveWithSpeed(Vector3 startPos, Vector3 endPos, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | startPos | The local start position |
Vector3 | endPos | The local end position to move to |
System.Single | speed | The speed of the animation. When the distance is 1 unity unit with the speed 1 it will take 1 seconds to animate. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalRotate(Quaternion, Quaternion, Single, Func<Single, Single>)
Rotate the local transform which uses speed and not a duration.
Declaration
public TransformAnimator LocalRotate(Quaternion startRotaion, Quaternion endRotation, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | startRotaion | The end rotation after the animation |
Quaternion | endRotation | The end rotation after the animation |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalRotate(Quaternion, Single, Func<Single, Single>)
Rotate the local transform which uses speed and not a duration. The start rotation will be the current rotation of the Transform (before the start of the hole animation).
Declaration
public TransformAnimator LocalRotate(Quaternion endRotation, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | endRotation | The end rotation after the animation |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalRotateWithSpeed(Quaternion, Quaternion, Single, Func<Single, Single>)
Rotate the local transform which uses speed and not a duration.
Declaration
public TransformAnimator LocalRotateWithSpeed(Quaternion startRotaion, Quaternion endRotation, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | startRotaion | The start rotation |
Quaternion | endRotation | The end rotation after the animation |
System.Single | speed | The speed of the animation. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LocalRotateWithSpeed(Quaternion, Single, Func<Single, Single>)
Rotate the local transform which uses speed and not a duration.The start rotation will be the current rotation of the Transform (before the start of the hole animation).
Declaration
public TransformAnimator LocalRotateWithSpeed(Quaternion endRotation, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | endRotation | The end rotation after the animation |
System.Single | speed | The speed of the animation. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LoopExecute()
Loop all added animations and sequences till the animator is stopped manually Stop()
Declaration
public TransformAnimator LoopExecute()
Returns
Type | Description |
---|---|
TransformAnimator | it self |
LoopExecute(Int32)
Loop all added animations and sequences for a certain count
Declaration
public TransformAnimator LoopExecute(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | The number of iterations |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Move(Vector3, Single, Func<Single, Single>)
Add a Move animation. Animate form current position (before the start of the hole animation) till pos
Declaration
public TransformAnimator Move(Vector3 pos, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | pos | The position to move to |
System.Single | duration | The duration of the animation in seconds |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Move(Vector3, Vector3, Single, Func<Single, Single>)
Add a Move animation.
Declaration
public TransformAnimator Move(Vector3 startPos, Vector3 endPos, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | startPos | The position to move to |
Vector3 | endPos | The position to move to |
System.Single | duration | The duration of the animation in seconds |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
MovePath(IList<Vector3>, IList<Single>, Func<Single, Single>)
Move the transform along a path. The start point will be the current position of the Transform (Do not include this position in the path IEnumerable) Example how the different parameters will be applied
transform.postion path[0]
o ------------------durations[0]-----------►•
│
durations[1]
│
▼
•◄------------------durations[2]------------•
path[2] path[1]
Declaration
public TransformAnimator MovePath(IList<Vector3> path, IList<float> durations, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
IList<Vector3> | path | The path points without the current transform position |
IList<System.Single> | durations | The duration |
Func<System.Single, System.Single> | easeFunction | The ease function will be applied for each transition form point to point and not for the hole animation |
Returns
Type | Description |
---|---|
TransformAnimator | The TramsformAnimator |
MovePath(IList<Vector3>, Single, Func<Single, Single>)
Move the transform along a path. The start point will be the current position of the Transform (Do not include this position in the path IEnumerable)
Declaration
public TransformAnimator MovePath(IList<Vector3> path, float durations, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
IList<Vector3> | path | The path points without the current transform position |
System.Single | durations | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease function will be applied for each transition form point to point and not for the hole animation |
Returns
Type | Description |
---|---|
TransformAnimator | The TramsformAnimator |
MovePath(Single, Func<Single, Single>, Vector3[])
Move the transform along a path. The start point will be the current position of the Transform (Do not include this position in the path IEnumerable)
Declaration
public TransformAnimator MovePath(float duration, Func<float, float> easeFunction = null, params Vector3[] path)
Parameters
Type | Name | Description |
---|---|---|
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease function will be applied for each transition form point to point and not for the hole animation |
Vector3[] | path | The path points without the current transform position |
Returns
Type | Description |
---|---|
TransformAnimator | The TramsformAnimator |
MoveWithSpeed(Vector3, Single, Func<Single, Single>)
Add a Move animation which uses speed and not a duration. Animate form current position (before the start of the hole animation) till pos
Declaration
public TransformAnimator MoveWithSpeed(Vector3 pos, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | pos | The position to move to |
System.Single | speed | The speed of the animation. When the distance is 1 unity unit with the speed 1 it will take 1 seconds to animate. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
MoveWithSpeed(Vector3, Vector3, Single, Func<Single, Single>)
Add a Move animation which uses speed and not a duration.
Declaration
public TransformAnimator MoveWithSpeed(Vector3 startPos, Vector3 endPos, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | startPos | The start position |
Vector3 | endPos | The end position to move to |
System.Single | speed | The speed of the animation. When the distance is 1 unity unit with the speed 1 it will take 1 seconds to animate. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Rotate(Quaternion, Quaternion, Single, Func<Single, Single>)
Rotate the transform.
Declaration
public TransformAnimator Rotate(Quaternion startRotation, Quaternion endRotation, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | startRotation | The start rotation after the animation |
Quaternion | endRotation | The end rotation after the animation |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Rotate(Quaternion, Single, Func<Single, Single>)
Rotate the transform. The start rotation will be the current rotation of the Transform (before the start of the hole animation).
Declaration
public TransformAnimator Rotate(Quaternion endRotation, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | endRotation | The end rotation after the animation |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
RotateWithSpeed(Quaternion, Quaternion, Single, Func<Single, Single>)
Rotate the transform which uses speed and not a duration.
Declaration
public TransformAnimator RotateWithSpeed(Quaternion startRotaion, Quaternion endRotation, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | startRotaion | The end rotation after the animation |
Quaternion | endRotation | The end rotation after the animation |
System.Single | speed | The speed of the animation. When the rotation distance is 1 Euler angle and the speed is 1 second the animation will take 1 second. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
RotateWithSpeed(Quaternion, Single, Func<Single, Single>)
Rotate the transform which uses speed and not a duration. The start rotation will be the current rotation of the Transform (before the start of the hole animation).
Declaration
public TransformAnimator RotateWithSpeed(Quaternion endRotation, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | endRotation | The end rotation after the animation |
System.Single | speed | The speed of the animation. When the rotation distance is 1 Euler angle and the speed is 1 second the animation will take 1 second. |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Scale(Vector3, Single, Func<Single, Single>)
Add a scale animation. Animate from the current scale (before the start of the hole animation) till scale
Declaration
public TransformAnimator Scale(Vector3 scale, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scale | The end scale of the animation |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Scale(Vector3, Vector3, Single, Func<Single, Single>)
Add a scale animation.
Declaration
public TransformAnimator Scale(Vector3 startScale, Vector3 endScale, float duration, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | startScale | The start scale of the animation |
Vector3 | endScale | The end scale of the animation |
System.Single | duration | The duration of the animation |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
ScaleWithSpeed(Vector3, Single, Func<Single, Single>)
Add a scale animation which uses speed and not a duration. Animate from the current scale (before the start of the hole animation) till scale
Declaration
public TransformAnimator ScaleWithSpeed(Vector3 scale, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | scale | The end scale of the animation |
System.Single | speed | The speed of the animation. When the scale has a difference of 1 unit with the speed of 1 it takes 1 second to animate |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
ScaleWithSpeed(Vector3, Vector3, Single, Func<Single, Single>)
Add a scale animation which uses speed and not a duration.
Declaration
public TransformAnimator ScaleWithSpeed(Vector3 startScale, Vector3 endScale, float speed, Func<float, float> easeFunction = null)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | startScale | The start scale of the animation |
Vector3 | endScale | The end scale of the animation |
System.Single | speed | The speed of the animation. When the scale has a difference of 1 unit with the speed of 1 it takes 1 second to animate |
Func<System.Single, System.Single> | easeFunction | The ease functions to use for the interpolation |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
Sequence(Single)
Create a sequence of Animation which all take the same amount of time
Declaration
public TransformAnimatorDurationSequence Sequence(float duration)
Parameters
Type | Name | Description |
---|---|---|
System.Single | duration | The duration of the sequence |
Returns
Type | Description |
---|---|
TransformAnimatorDurationSequence | A new sequence object to chain animations on |
Stop()
Stop the animation. After stopping the animation the object will be disposed and cannot be used again.
Declaration
public void Stop()
WaitForCondition(WaitForCondition.TimePredicate)
Wait till a certain condition is true
Declaration
public TransformAnimator WaitForCondition(WaitForCondition.TimePredicate condition)
Parameters
Type | Name | Description |
---|---|---|
WaitForCondition.TimePredicate | condition | The condition to wait for |
Returns
Type | Description |
---|---|
TransformAnimator | it self |
WaitForSeconds(Single)
Wait for x seconds and the continue with the next animation
Declaration
public TransformAnimator WaitForSeconds(float duration)
Parameters
Type | Name | Description |
---|---|---|
System.Single | duration | Time to wait in seconds |
Returns
Type | Description |
---|---|
TransformAnimator | it self |