How to do it...

To export a 2D sprite animation from a 3D package and import it into Unity, follow these steps:

  1. Create an animated object in your chosen 3D package.
  2. Set the camera to render out the animated object. The camera can be perspective or orthographic, depending on what you would like to achieve. In this example (a rotating coin), it is set to perspective to better show the animation. Try to have the center of your object in the center of the frame.
  3. Render the animation into separate frames with a transparent background (often 12 frames per second is enough for a good quality sprite animation). Use a logical naming convention (for example, frame_01.png, frame_02.png, and so on). All the frames should have the same size in pixels.
  4. Create a new image in a chosen image editing software (we are using GIMP in this recipe). The image should have a transparent background.
  1. Count all your rendered frames and set the size of the newly created image to be big enough to contain all the rendered frames, one next to another (in columns and rows). For example, an image of 512 × 512 pixels size can contain up to 8 frames of 256 × 256 size, 16 frames of 128 × 128 size, or 32 frames of 64 × 64 size.
  2. Place all the frames next to each other on the newly created image (in columns and rows), starting from the first frame, as shown in the following screenshot:
  1. Export the image as a *.png file with transparent background.
  2. Import the image to Unity (drag and drop it to the Project View or go to Assets | Import New Asset and choose the image file in the explorer).
  1. Select the imported file in the Project View and go to the Inspector. Set the Texture Type to Sprite (2d and UI), as shown in the following screenshot:
  2. Set the Sprite Mode to Multiple, click on the Apply button (to save the settings), and then click on the Sprite Editor button.
  3. The Sprite Editor window will open, as shown in the following screenshot:
  1. Click on the Slice button, a dialog with additional settings will appear.
  2. Set the Type to Automatic, Pivot to Center, and click on the Slice button.
  3. To finish the editing, click on the Apply button and close the Sprite Editor window.
  4. The texture asset will be turned into a sprite asset with all the frames as separate children: sprites with numbers added to their names, as shown in the following screenshot:
  1. You can use those children sprites as static 2D graphics or create an animation in the Animation View.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.182.96