In order for sprites to be imported into Unity, they must be in jpg format and have to be cropped.
Prepare 2D assets for import into Unity
Assets can be imported into Unity. It makes sense to save the sprites in the asset folder. Sub-folders can be created underneath, which are sorted according to scenes, characters or any other organizational structure that fits your project.
It is important to clearly name the assets. It makes sense to design the name like: Title_Screen_background. If a sprite belongs to an animation, it makes sense to give each frame the same name and then to number them so that Unity lists them in the appropriate project window.
Unity can import 2D assets from individual folders. Every UI element or every frame of an animation appears in an individual folder, in which it makes sense to collect many assets in a single image, such as a Sprite Sheet or Sprite Atlas. For example, it makes sense to collect animation frames together so that a sprite sheet only contains one animation. This will later facilitate the workflow and you can automatically subdivide and name the sprites. Most tools are capable of exporting Sprite Sheeds. The sprites can be named automatically.
Another point where it makes sense to collect individual elements on a single sheet is when arranging sprites for tilemaps.
Import individual sprites
It is possible to import a single sprite. Unity names the sprite after the image name. For example, if the image is named Chimney.png, Unity also names it a Chimney. To do this, open a 2-D project in Unity and simply drag it into the project window or anywhere in the asset area using Windows Explorer.
You click on the newly imported sprite in the project window and open the inspector window for the import settings.
The following settings are relevant here:
Pixels per unit:
Pixels per Unit indicates how many pixels the sprite contains and what size it takes up in Unity. As a rule, the setting is identical for all sprites in the project. In most cases, you'll select them before creating your asset. Sprites can be scaled and adapted to each other. This is reflected in the game world and in the orthographic camera.
For projects with high resolution graphics or a special visual style, the number can be set arbitrarily. This setting is useful if you program tile-based games and adapt the pixels per unit to the game world. This simplifies the construction of play worlds.
Another point is to what extent the game world should be recognizable on the screen. The relationship is with the orthographic camera size. For example, for a retro game, the sprite is reduced to 16 × 16.
Pivot
The pivot is the attachment point for sprites. For example, stalactites can hang from the ceiling and you choose the position or height at which they are attached. For characters and decorative elements, this means standing on the floor of the game world. Then it makes sense to set it to bottom. There are 10 options for this area. These are 3 horizontal positions, the center and the corners, which can be combined with 3 vertical positions or your own user settings. The specification takes place between 0 and 1 in both dimensions. The Center setting is useful for most sprites.
Filter mode
It determines the graphic quality of the sprites. The options are Point (no filter), Bilinear, and Trilinear. The point mode (Point) helps z. B. Skip pixels to make the sprites appear larger or smaller. Bilinear means 2D smoothing, which makes sense when it comes to high resolution or photo-based 2D elements. Trilinear ensures a good mix between the mipmaps, which are not typical for 2D.
Import and configure multiple sprites in a single image with the Sprite Editor
Importing multiple sprites into a single image is not much different than importing a single sprite. However, you will need the Sprite Editor to break up the sprites and name them. Then you place them at their destination.
You first create or download an image with different sprites and import them into your project.
Then select an image in the project window to open the inspector window.
You set the Sprite Mode to multiple.
Then you set Pixels Per Unity and the filter mode to the values you need for your game and click on "Apply".
Select the Sprite Editor to open the Sprite Editor window.
First the image has to be divided into sprites. So choose Slice at the top, in the left corner of the Sprite Editor.
Cropping options:
automatically: The Sprite Editor detects areas that are transparent and classifies them as sprites.
Grid by Cell Size: The grid is cut evenly, with the user specification defining the size of each cell. This is the most common option when it comes to tile-based projects or projects where the sprites on a sheet are the same size (icons or other interface elements or world building blocks).
Grid by Cell Count: The grid is cut evenly, indicating the number of rows and columns of sprites. For example, you can choose this option instead of Grid by Cell Size if your sprite sheet was generated by a program in which you have already divided rows and columns.
The Cell size is defined by pixel size or columns and row count, depending on the non-automatic setting you have selected.
Offset allows you to place a marker at the top left corner of your sprite sheet. It is useful in situations where the sprites are separated by a grid.
Padding inserts spaces between the sprites.
It makes sense to have sprites separated by a grid:
- Select the options and click on Slice
- Find the sprite names that are to be combined into an original image and the sprite position in the section of the sprite (requirement is a left-to-right arrangement or a top-to-bottom reading instruction), starting with 0.
- Click on the sprite to select it. Now rename it and determine its position and size and add borders (for a 9-slicing).
- To create a new sprite without needing a cutting tool (or after you've used it), click anywhere in the picture (starting on the outside, with an existing sprite, otherwise just select it and move it) and drag it to the required position to create a sprite
- after you have selected it, you can delete selected sprites. This does not mean that part of an image will be deleted. You can adjust the corners of the sprite and use them to adjust the size. If you hold down Ctrl while you do this, you will change the edges of the sprite.
- When you're done, click Apply and close the Sprite Editor window.
This is all that is needed to import 2D assets into Unity. The settings depend on the size of the project and over time you will find out which settings you need most.
Originally posted on 2020-01-14 11:58:00.