Jump to content

Unity/Sprites and Sprite Sheets

From Wikibooks, open books for an open world

What are Sprites?

[edit | edit source]
  • Sprites are 2D images or animations that represent objects in your game. These can be anything from characters, enemies, and props to backgrounds and effects.
  • In Unity, sprites are used as textures that you can apply to game objects.

Sprite Sheets

[edit | edit source]
  • Sprite Sheets (or texture atlases) are a collection of multiple sprites packed into a single texture.
  • Using sprite sheets helps in optimizing the game by reducing the number of texture loads and draw calls.

Importing Sprites

[edit | edit source]
  • Import your sprite assets into Unity by dragging and dropping them into the Project window, or just saved it into the project
  • Select the sprite in the Project window.
  • In the Inspector window, set the Texture Type to Sprite (2D and UI).
  • Click Apply to finalize the settings.

Importing Sprite Sheets

[edit | edit source]

To use individual sprites from a sprite sheet, you need to slice the sheet:

  • Select the sprite sheet in the Project window.
  • In the Inspector window, change the Sprite Mode to Multiple.
  • Click on the Sprite Editor button.
  • In the Sprite Editor window, use the Slice tool to divide the sprite sheet into individual sprites. You can do this manually or use the Automatic option.
  • Click Apply to save your changes.

Using Sprites

[edit | edit source]

Sprite Renderer: This component is responsible for displaying the sprite in the game. You can configure it in the Inspector window, adjusting properties such as the sprite, color, flip, and more.