The “Generate Sprite Sheet” panel will pop up. Change settings to ideal format and size. In this particular case, the animation is large enough for 1024×1024. We are exporting an png and well as the JSON data. In Unity, we will use the information to edit the sprite sheet in the editor.
Press Export and we will import the PNG into Unity.
Open up a Unity project and import the sprite sheet into your asset folder. With the Inspector displayed, select the sprite sheet image in the assets folder. Initially the import settings may set the sprite sheet image as a regular texture. This needs to be changed to Sprite (2D and UI). Also change the sprite mode to Multiple. This allows us to edit the sprite into multiple slices. Here is what you should see:
Other settings of interest:
Packing Tag : Define the sprite atlas tag name. In this case keep the default.
Pixels Per Unit: one unit in unity, not necessarily one pixel, default 100:1 – I have manipulated for scale or if I wanted to keep a size consistency. Default is the better setting. This setting is applicable to obtain pixel perfect quality. It is related to the size defined in the camera. More about this in another blog.
Generate Mip Maps: To generate smaller versions of the sprite for smaller screens. This is a way of optimizing the performance when this display is farther away from the camera. More or less a 3D feature.
Filter Mode: How the texture is displayed when stretched within a transform. Not as applicable here. Keep the default.
- Max Size : The suitable max size of the sprite texture. It is best to keep this around current size of the image. This helps for performance. Vary this between quality and optimal size
- Format : The compression format of the image. Again vary this between quality and size. Compressed is the less quality better size and Truecolor is the best quality more size.
Press the Sprite Editor Button to open the Editor Panel. If you click on to the Slice Menu, you can either manually slice, or auto slice. Since the sprite sheet was created with consistent slice sizes, we will choose the later. You will have the option to either automatically slice the sprite sheet or set of a grid. It is also important to note that pivot point set to static areas (top, center, bottom, etc).
If you choose manually slice, you can take the values of width and height from the JSON data and plug in the height and width of the slice. You can manually more the pivot anchor just in case the slice is off for you animation. Very useful! This is also a good way to check the auto slice cuts, like I show here. It would be nice have an JSON import feature here if there are unique sprite slices.
Press apply and now we have our animation imported into Unity. You are ready create an animation.
Keep in mind that there are many methods to this production workflow. This is just one workflow to import sprite sheet into Unity. The spritesheet image asset can be found here. Please leave any comments or ideas about this process.
Next time, create a 2D animation using the Mecanim system.
Links of interest: