Overview
2D game worlds are built with image assets called Sprites. Characters, backgrounds, items, UI elements—virtually all on-screen graphics are Sprites. Unity provides powerful tools for efficiently managing and displaying these 2D images.
When dealing with multiple sequential images like character animations, managing them as individual files is inefficient. Instead, we use Sprite Sheets (or Texture Atlases)—techniques that pack multiple images into a single large texture. This provides major benefits: reduced draw calls (better rendering performance) and simplified asset management.
This article covers the basics of handling Sprites in Unity and how to slice sprite sheets using the Sprite Editor for animations.
The image above shows a sprite sheet for slime character animation. Animation frames are arranged in a single image like this.
What is a Sprite?
When you import image files (PNG, JPEG, etc.) into a Unity project, the default Texture Type is Default (3D texture). To use it as a 2D Sprite, you need to change the settings in Inspector.
- Select the image asset in the Project window.
- Change the
Texture Typedropdown at the top of Inspector toSprite (2D and UI). - Click
Applyto apply the changes.
The image asset is now a Sprite that can be dragged into the scene. Sprites placed in scenes are rendered by the Sprite Renderer component.
Sprite Sheets and Sprite Editor
Sprite sheets are single images containing sequential frames of character movements—walking, running, jumping—arranged like film frames. To use sprite sheets in Unity, you need to slice them into individual images using the Sprite Editor.
How to Slice with Sprite Editor
-
Change Sprite Mode: Select the image asset you want to use as a sprite sheet. In Inspector, change
Sprite ModefromSingletoMultiple. -
Open Sprite Editor: Click the
Sprite Editorbutton to open the Sprite Editor window. -
Automatic Slicing:
- Click the
Slicemenu at the top-left of Sprite Editor. - Ensure
Typeis set toAutomatic, then clickSlice. - Unity analyzes transparent areas and automatically detects individual sprites, surrounding them with rectangles.
- Click the
-
Grid Slicing (Grid by Cell Size):
- When sprites are neatly arranged in a uniform grid, precise grid slicing is more convenient.
- Change
TypetoGrid by Cell Sizein theSlicemenu. - Enter the width and height (in pixels) of each sprite in
Pixel Size, then clickSlice.
-
Manual Adjustment: If automatic slicing doesn't work well, you can drag to create/edit rectangles manually. You can also set individual sprite names and pivots (center points).
-
Apply: When finished slicing, click
Applyat the top-right of Sprite Editor to save changes. Forgetting this step loses all slicing information.
After clicking Apply, clicking the arrow next to the sprite sheet asset in Project window reveals the sliced individual sprites as child assets. Use these individual sprites for creating animation clips or assigning to Sprite Renderer.
Why Use Sprite Sheets?
- Performance improvement: When multiple
Spritesshare the same texture (sprite sheet), Unity tries to render them in a single draw call (static/dynamic batching). This significantly reduces CPU load and improves overall game performance. - Easier management: Combining related images into one file simplifies project asset management. Fewer files also reduces project load times.
- Memory efficiency: Loading one large image is more memory-efficient (less fragmentation) than loading many individual image files.
Summary
Sprites and sprite sheets are fundamental to Unity 2D game development.
- Set
Texture TypetoSprite (2D and UI)for 2D images. - Combine sequential images into sprite sheets for performance and management benefits.
- Set
Sprite ModetoMultipleand slice withSprite Editor. - Slicing options include
AutomaticandGrid by Cell Size—use appropriately for your situation.
Mastering the Sprite Editor for efficient sprite sheet management is the first step toward creating high-quality 2D games.