Table of Contents

BindableAnimator

BindableAnimator lets you smoothly animate a bindable float along a curve. You can then use this animated float in place of any IBindable<float> to create smooth animations and transitions.

var animator = new BindableAnimator(Curve.EaseOutCubic(2f), autoPlay: true);

Curve defines the curve function for the animator. You can pass in a Unity AnimationCurve, or create a simple easing curve using one of the Ease static methods. Easing curves always start at 0 and end at 1, so the animator above will animate from 0 to 1 over 2 seconds.

The easing functions were copied from easings.net.

Now you can bind to the animator. This will move the current gameObject from (0, 0, 0) to (0, 1, 0) over 2 seconds:

transform.BindPosition(animator, v => new Vector3(0, v, 0));

BindableAnimator has several control functions:

  • Play - play the animation, optionally from the beginning.
  • PlayReverse - play the animation backwards.
  • Pause - stop the animation at its current tme.
  • CurrentTime - get or set the current animation time.
  • Curve - get or set the animation curve
  • Value - read the current value.
  • Loop - control if the animation should wrap or ping-pong.
  • IsPlaying - true if the animation is currently playing.
  • IsReverse - true if the animation is currently playing in reverse.
  • WaitForCompleteAsync - an async function to wait for the animation to complete.