How to animate 2D sprite frame by frame.

I have 10 images representing a sprite animation. I managed to animate a sprite by making a script with a public list, then in the inspector I manually add the 10 sprites to the list and make the script iterate each sprite in the list to modify the Sprite Renderer component.

This works. But is there a more correct way to do this?

Make sure all the sprites you want to animate are parented to 1 object.
Open the animation window ( Window → Animation ).
Click on the object that is the parent of all the sprites you want to animate.
Hit the shiny red button on the animation window, give the animation clip a name, and have fun animating.
You can google around for how to use the animation window.

  1. Create an empty Gameobject and add a sprite renderer component.
  2. Select the object and go to Window → Animation.
  3. Click the dropdown box next to sample rate (the two opposite facing arrows) and create a new clip. Give it a name and save it.
  4. You can now drag each image onto the timeline in order. When you drag the first one on it will create a “curve” which animates the sprite property of the sprite renderer. By switching the sprite each frame you can create an animation.

Unity 5.5: Follow MikeNewall’s steps above EXCEPT #4.

Instead:

  1. Click “Add Property”, and navigate to the name of your sprite, expand it
  2. Find “Sprite Renderer” and expand that
  3. Find “Sprite” and then click the + icon to the right of it.
  4. You’ll now see a thumbnail version of your sprite in the timeline itself.
  5. You can create animation keys, select a key, then in the inspector change what image the sprite is displaying in that frame !