Class ValueAnimation<T>
Implementation object for transition animations.
Namespace: UnityEngine.UIElements.Experimental
Syntax
public sealed class ValueAnimation<T> : object, IValueAnimationUpdate, IValueAnimation
Type Parameters
Name | Description |
---|---|
T |
Constructors
ValueAnimation()
Constructor.
Declaration
public ValueAnimation()
Remarks
To properly use object pooling, use the Create static function.
Properties
autoRecycle
Returns true if this animation object will be automatically returned to the instance pool after the animation has completed.
Declaration
public bool autoRecycle { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
durationMs
Duration of the animation in milliseconds.
Declaration
public int durationMs { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
easingCurve
Smoothing function related to this animation. Default value is OutQuad(Single).
Declaration
public Func<float, float> easingCurve { get; set; }
Property Value
Type | Description |
---|---|
Func<Single, Single> |
from
The animation start value.
Declaration
public T from { get; set; }
Property Value
Type | Description |
---|---|
T |
initialValue
Callback invoked when the from field has not been set, in order to retrieve the starting state of this animation.
Declaration
public Func<VisualElement, T> initialValue { get; set; }
Property Value
Type | Description |
---|---|
Func<VisualElement, T> |
interpolator
Value interpolation method.
Declaration
public Func<T, T, float, T> interpolator { get; set; }
Property Value
Type | Description |
---|---|
Func<T, T, Single, T> |
isRunning
Tells if the animation is currently active.
Declaration
public bool isRunning { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
onAnimationCompleted
Callback invoked when this animation has completed.
Declaration
public Action onAnimationCompleted { get; set; }
Property Value
Type | Description |
---|---|
Action |
to
The animation end value.
Declaration
public T to { get; set; }
Property Value
Type | Description |
---|---|
T |
valueUpdated
Callback invoked after every value interpolation.
Declaration
public Action<VisualElement, T> valueUpdated { get; set; }
Property Value
Type | Description |
---|---|
Action<VisualElement, T> |
Methods
Create(VisualElement, Func<T, T, Single, T>)
Creates a new ValueAnimation object or returns an available one from it's instance pool.
Declaration
public static ValueAnimation<T> Create(VisualElement e, Func<T, T, float, T> interpolator)
Parameters
Type | Name | Description |
---|---|---|
VisualElement | e | |
Func<T, T, Single, T> | interpolator |
Returns
Type | Description |
---|---|
ValueAnimation<T> |
Ease(Func<Single, Single>)
Sets the easing function.
Declaration
public ValueAnimation<T> Ease(Func<float, float> easing)
Parameters
Type | Name | Description |
---|---|---|
Func<Single, Single> | easing |
Returns
Type | Description |
---|---|
ValueAnimation<T> |
KeepAlive()
Will not return the object to the instance pool when the animation has completed.
Declaration
public ValueAnimation<T> KeepAlive()
Returns
Type | Description |
---|---|
ValueAnimation<T> |
OnCompleted(Action)
Sets a callback invoked when this animation has completed.
Declaration
public ValueAnimation<T> OnCompleted(Action callback)
Parameters
Type | Name | Description |
---|---|---|
Action | callback |
Returns
Type | Description |
---|---|
ValueAnimation<T> |
Recycle()
Returns this animation object into its object pool.
Declaration
public void Recycle()
Implements
Remarks
Keeping a reference to the animation object afterwards could lead to unspecified behaviour.
Start()
Starts the animation using this object's values.
Declaration
public void Start()
Implements
Stop()
Stops this animation.
Declaration
public void Stop()
Implements
Remarks
If set, the onAnimationCompleted callback will be called.