UIAnimation
A Tweenslator animation is a set of parameters used to create one or more Tweens and manage them at the same time.
Although you can create them by code it is preferable to create them with an animator.
Lifecycle
An animation requires a target GameObject to be created.
After being instantiated, it is considered not to have started until the Play()
function is called.
The Tweens ids are then saved by the animation.
The animation functions call the appropriate method of the Tweenslator class to propagate the requested action to the Tweens.
For the animation to end, each associated Tween must end.
The animation monitors the events of its Tweens and counts their triggers so that it can trigger its own start, loop and end events.
Effects
Loop
Let's start with the "loop" effect.
It repeats the other effects in one of the two directions (Restart or Oscillate).
Set the number of loop value to -1 for an infinite number of loops.
Because of the way loops are counted in an animation, several effects of different durations can end up inducing an inconsistent triggering of the loop event.
So depending on your objectives, if you want to react specifically to a loop event, we recommend that you separate the effects into different animations.
This way, all you have to do is choose the OnLoop
event to which you want to add a callback.
Alternatively, give the different effects the same duration so that they loop simultaneously.
Other Effects
Each one of the other effects has a duration, a delay, start and/or end values and an easing function.
They also have specific parameters.
- Move effect : "Position Mode" lets you choose between human-readable or Vector3 start and end values.
- Fade effect : can be propageted to GameObject's children if you tick the "fade children" box. Please note that this option makes the current GameObject responsible for the alpha of its children.
- The scale effect : has no additional parameters. It simply has a Vector3 type variable as start and end values.
- The rotate effect : can only be applied around one of the GameObject's X, Y or Z axis.
Additional resources
- UIAnimation scripting api class reference
- UIAnimator get started guide reference
- GameObject external resource
- RectTransform external resource
- UnityEvent external resource
- Vector3 external resource
- Easing Functions external resource
- Robert Penner's easing equations external resource