How it works
It all comes down to a MonoBehaviour responsible for animating GameObjects by changing the sprites of a SpriteRenderer based on the FPS defined for that particular animation.
Work flow
- Attach the SpriteAnimator component to a GameObject and feed it a SpriteRenderer.
- Then you will use the Animations Manager window to organize all the animations that animator can play during runtime.
- Create a Script (or scripts) and tell the animator wich animation to play using the Play() method:
Playing animations
Just tell the animator to play it:
public SpriteAnimator _animator;
private void Start()
{
_animator.Play("Idle");
}
or, if you do not like working with strings, you can reference an animation through inspector and use it:
public SpriteAnimator _animator;
public SpriteAnimation _idleAnimation;
private void Start()
{
_animator.Play(_idleAnimation);
}