Loading lessons...
2D Assets & Sprites
2D Assets & Sprites
Unity features a comprehensive set of workflows built specifically for 2D game development. The foundation of any 2D game is the Sprite.
Sprites and Texture Types
When you import an image file (like .png or .jpg) into Unity, it is imported as a Texture. To use it in a 2D game:
- Select the image in the Project Window.
- Change its Texture Type in the Inspector to Sprite (2D and UI).
- Click Apply.
Sprite Mode
- Single: The image file contains exactly one sprite.
- Multiple: The image is a sprite sheet containing multiple smaller images (like frames of an animation or different map elements).
The Sprite Editor
For textures set to Multiple mode, click the Sprite Editor button in the Inspector:
- Use the Slice tool to automatically or manually slice the sprite sheet into individual sprites.
- You can adjust the Pivot Point (the origin point for rotation and scaling) of each sprite.
- Click Apply to save the sliced sprites. They appear nested under the main texture asset.
Rendering Sprites
To display a sprite in the scene, add a Sprite Renderer component to a GameObject:
- Sprite: The specific sprite asset to draw.
- Color: Tint or fade the sprite.
- Flip: Flip the sprite along X or Y axes.
- Sorting Layer & Order in Layer: Controls the rendering order. Objects in layers with higher orders are drawn on top of objects with lower orders, regardless of their Z position.
TL;DR
- Import images as Sprite (2D and UI) Texture Type.
- Slicing sprite sheets is managed via the Sprite Editor.
- The Sprite Renderer draws sprites in the Scene.
- Sorting Layer and Order in Layer determine what gets rendered in front.