Class BindableAnimator
- Namespace
- Bindables
- Assembly
- Bindables.dll
A bindable animator that evaluates a curve over time and provides the animated value through the IBindable interface. Supports play, pause, reverse, and various loop modes for animation control.
public class BindableAnimator : IBindable<float>, IBindable
- Inheritance
-
BindableAnimator
- Implements
- Inherited Members
- Extension Methods
Constructors
BindableAnimator(Curve, float, float, bool, LoopType)
Creates a BindableAnimator class with the specified initial value and curve.
public BindableAnimator(Curve curve, float startValue = 0, float endValue = 1, bool autoPlay = false, BindableAnimator.LoopType loop = LoopType.None)
Parameters
curveCurveThe curve to use for animation evaluation.
startValuefloatThe initial value time == 0
endValuefloatThe final value when time == curve.Duration
autoPlayboolIf true, the animation will start playing immediately. Default is false.
loopBindableAnimator.LoopTypeThe loop type for the animation. Default is None.
Properties
CurrentTime
Gets or sets the current time position in the animation. The value is clamped between 0 and the curve's duration. Setting this property will update the current value.
public float CurrentTime { get; set; }
Property Value
Curve
Gets or sets the curve used for animation evaluation. Setting this property will update the current value.
public Curve Curve { get; set; }
Property Value
EndValue
public float EndValue { get; set; }
Property Value
IsPlaying
Whether the animation is currently playing.
public bool IsPlaying { get; }
Property Value
IsReverse
Whether the animation is set to play in reverse.
public bool IsReverse { get; }
Property Value
Loop
Gets or sets the loop type for the animation.
public BindableAnimator.LoopType Loop { get; set; }
Property Value
StartValue
public float StartValue { get; set; }
Property Value
Value
Gets the current value of the animation based on the curve evaluation at the current time.
public float Value { get; }
Property Value
Methods
BindTransition(IBindable<bool>)
Binds a boolean transition that will control the animation playback. When the transition value is true, the animation plays forward; when false, it plays in reverse.
public void BindTransition(IBindable<bool> transition)
Parameters
transitionIBindable<bool>The bindable boolean to use for controlling animation direction. Pass null to unbind.
Pause()
Pauses the animation at the current time position.
public void Pause()
Play(bool)
Starts playing the animation in the forward direction.
public void Play(bool playFromBeginning = false)
Parameters
playFromBeginningboolIf true, resets the current time to 0 before playing. Default is false.
Play(float, float)
Updates the start and end values and plays the animation in the forward direction.
public void Play(float startValue, float endValue)
Parameters
PlayReverse(bool)
Starts playing the animation in the reverse direction.
public void PlayReverse(bool playFromEnd = false)
Parameters
playFromEndboolIf true, resets the current time to the curve's duration before playing. Default is false.
PlayReverse(float, float)
Updates the start and end values and plays the animation in the reverse direction.
public void PlayReverse(float startValue, float endValue)
Parameters
WaitForCompleteAsync()
Awaitable method to wait until the currently running animation to complete or is stopped. Looping animations do not complete.
public Task WaitForCompleteAsync()
Returns
Events
OnChange
Event triggered when the bindable value changes.
public event Action OnChange
Event Type
OnChangeWithValue
Event triggered when the bindable value changes, providing the new value.
public event Action<float> OnChangeWithValue