Add and edit sprites
Add sprites to a 2D scene, use placeholder shapes and your own images, slice sprite sheets in the Sprite Editor, and set how sprites draw and sort in Unity Spark.
Read time 5 minutesLast updated 3 hours ago
Sprites are the flat images that make up a 2D game, such as characters, items, and scenery. For how sprites fit into a 2D game, refer to Introduction to 2D games in Unity Spark.
Add a sprite
To add a sprite to your scene:
- In the Hierarchy window, select Add object (+) or right-click.
- Select 2D Object > Sprite.
A new sprite renders as a white square, so it appears in the Scene view immediately. To change what it shows, set its Sprite in the SpriteRenderer component. For a description of each property, refer to SpriteRenderer properties.
Use placeholder sprites
To lay out a rough version of a level before you have art, use the white placeholder shapes in the Built-in source of the Project window. Resize them with the object's scale. The following table describes the shapes and what you can use them for.
Shape | Use |
|---|---|
| Triangle | A stand-in for obstacles, such as spikes or ramps. |
| Square | A stand-in for platforms, walls, and obstacles. |
| Circle | A stand-in for round objects, such as balls, coins, or props. |
| Capsule | A stand-in for a character. |
| Isometric Diamond | A stand-in for tiles on an isometric tilemap. |
| Hexagon Flat Top | A stand-in for tiles on a hexagonal flat top tilemap. |
| Hexagon Point Top | A stand-in for tiles on a hexagonal point top tilemap. |
| 9-Sliced | A square that stretches without distorting its corners, for platforms or panels of any size. |
When you place a shape from the Built-in source, Unity Spark adds it as a UI image on a Canvas. For 9-Sliced, Unity Spark sets the Image Type to Sliced, so you can stretch it without distorting its corners.
Use your own images
PNG and JPG images become sprites when you import them. For how to import files, refer to Add files to your project.
To change how an image works as a sprite, select it in the Project window. The Sprite section of the Inspector window contains the following settings.
Setting | Description |
|---|---|
| Sprite Mode | Determines whether the image is one sprite or several. Single uses the whole image as one sprite. Multiple lets you slice the image into several sprites, such as the frames of a sprite sheet. |
| Filter Mode | Sets how the image appears when scaled. Use Point (no filter) for crisp pixel art. |
| Pixels Per Unit | Sets how many pixels of the image fit in one unit of the scene. Higher values make the sprite smaller. Select Save to apply a change. |
| Open Sprite Editor | Opens the Sprite Editor window to slice the image, or to set its border and pivot. |
Slice a sprite sheet
A sprite sheet holds several frames or images in one file.
To split a sprite sheet into separate sprites:
- Select the image in the Project window.
- In the Inspector window, set Sprite Mode to Multiple.
- Select Open Sprite Editor.
- In the Sprite Editor window, select Slice.
- Select a Type:
- Automatic: Creates one slice for each separate shape in the image.
- Grid by cell size: Creates slices of a set size, in pixels.
- Grid by cell count: Creates a set number of columns and rows.
- Select Slice.
- If needed, adjust the slices:
- To draw a new slice, drag on an empty area.
- To move a slice, drag it. To resize it, drag its corners.
- To set a slice's pivot, drag its pivot handle, or select a Pivot in the side panel.
- To delete the selected slice, press Delete, or select Delete slice.
- Select Apply.
Each slice becomes a sprite you can use in a SpriteRenderer component, a tilemap, or a sprite animation. Unity Spark names new slices , , , in order. To rename a slice, select it and change its Name. Two slices can't have the same name.
sprite_0sprite_1sprite_2To discard your changes, select Revert. If you close the window without selecting Apply, Unity Spark doesn't save your changes.
Stretch a sprite and keep its corners
To stretch a sprite, such as a platform or a button, without distorting its corners:
- Open the image in the Sprite Editor window.
- Select the sprite and set its Border values to the size of the corners.
- Select Apply.
- On the sprite object, in the SpriteRenderer component, set Draw Mode to Sliced or Tiled.
- In the SpriteRenderer component, set Size.
For how the Sliced and Tiled modes stretch and repeat the sections of a sprite, refer to 9-slicing in the Unity Manual. The Unity Manual describes the Unity Editor, so its menus and windows differ from Unity Spark.
Set the sprite draw order
Sprites draw in order of their Sorting Layer, then their Order in Layer. Higher numbers draw on top. To add a sorting layer, select Add Sorting Layer in the Sorting Layer list. To flip a sprite, use Flip X or Flip Y.
Animate sprites
To create a sprite animation:
-
In the Project window, select Create (+) > 2D > Sprite Animation.Unity Spark creates a looping animation clip and an animation controller that plays it.
-
To add frames, drag sprite slices from the Project window onto the clip.
For more information, refer to Add and create animation clips.