This post deals with sprites and the sprite editor. The Sprite options as well as the possibilities offered by the Sprite Editor are discussed.
Create sprites
1. Drag and drop the image into the Unity project folder
2. Go to Assets –> Import new assets to import an image of your choice
Sprite atlases are images that contain a collection of non-sequential sprites. These contain images that are used as animation. There are a few important things to keep in mind when using the Sprite Editor. The sprite sheet should be a power of 2 to influence the size of the sprite in Unity (512 * 512, 1024 * 512, 1024 * 1024, etc.). To ensure that your sprite sheet asset works properly in the Unity Engine, the sprite mode should be set to "multiple". If Single is set, the Sprite Editor functions cannot be used.
Import settings
To make settings on the sprite, select the sprite in the project window. You can make various settings in the inspector window that opens.
The settings in the inspector window:
Texture Type: The texture type is regularly set to 2D and UI.
Sprite mode: Multiply contains several sprites, single refers to individual sprites
Packing day: This option is used in conjunction with Unity's Sprite Packer
pixels per unity: Here you can set how many pixels are used per sprite in the sprite sheet
Mesh type: Defines the mesh that is generated for the sprite. Narrow results in a mesh based on pixel alpha values. FullRect returns a mesh that matches the user-defined sprite size.
Extruded Edges: The number specified here determines how many pixels the narrow mesh type around the sprite results in, so that transparent pixels remain.
Wrap mode: A setting that determines how the animations are interpreted by the sprite sheet.
Filter mode: Determines the filter mode of the sprite.
In addition, there are advanced settings that can vary depending on requirements.
To activate this you have to open the extended menu in the import settings:
The following settings are available here:
sRGB (color texture)
alphasource
Alpha is transparency
Read/Write Enabled
Generate MipMaps
If the Sprite mode is set to Single, the Sprite Editor will not be seen.
The Sprite Editor
A sprite can be opened in the sprite editor:
It can be docked like any other Unity window.
Create sprites in the sprite editor
In the Sprite Editor you can click on a rectangle to create sprites. You can adjust this rectangle as required.
The squares of the Sprite Editor can be adjusted and moved as required. The size can also be changed by the sprite. You can also adjust the pivot point (the blue point) as required.
A small window opens in the Sprite Editor with information about the Sprite Editor window. The following options are available there:
Name: Name of the selected sprite, which is inherited from the image from which the sprite originates and from which it was cut. The numbering starts with 0.
Position: Position specifies the position of the image's sprite in pixels. X and Y determine the starting point of the sprite at the lower end of the left corner, where W in the H defines the width and height of the image from the starting point.
Borders: Boundaries can be defined inside the sprite up to the center.
Pivot: Allows you to define where the central point (blue circle) of the sprite is located. If a custom setting is selected, the X and Y positions are determined.
Sprite editor tools
At the top of the Sprite Editor is the bar with a variety of tools.
Sprite editor: The drop-down menu switches between three different tools: The Sprite Editor, Edit Oultine and Edit Physics Shape.
slice: Allows automatic cropping based on the closest pixel of the sprite. The cutting tool or slice tool offers the possibility of automatic cutting options, with which different cutting types can be selected. These include: automatically according to cell size (grid by cell size) or number of grids in grids. The central point is automatically placed and the method is adapted to how it was previously cut. This is the best option when using the Sprite Atlas with odd or strange sprite placements in the image. It's the best option to use the auto crop tool as well when it comes to animated sprite sheets. "Grid by Cell Size" should be set and the size of the sections should be set in order to keep the division of the successive sprites consistent.
Trims: Automatically cuts a selected segment to the smallest possible size based on the actual size of the sprite
reverse: Resets all changes made.
Apply: Confirms all changes made.
RGB Alpha Toggle: Switches the display of the Sprite Editor between the color image and the alpha channel. Click that button and your sprite image will turn black and white. Black for the alpha and white for the pixels of the sprite.
Zoom scroll: Allows you to zoom in and out with the mouse wheel.
Then there are two other tools: Edit outline and Edit physics shape:
Edit outline: opens another toolbar.
With this tool, the Sprite Editor shows outline and control points of the sprite. These control points are areas that you can move and manipulate. The outlines can also be manipulated. This is useful if transparent areas in the sprite can have a negative effect on your project performance. The tool can also be used to fine-tune the limits.
The points can be adjusted manually or you can realign the pixels with the alignment button. The tolerance control controls how closely the structure follows the sprite texture.
The Edit Physics Shape Tool: The tool allows to influence the shape of the games physics, which is predefined by the original shape of the sprite collider's 2D mesh. The tool allows further fine adjustments to the shape of the games physics through the component settings Collider to be carried out. It has the same setting options as the Edit Outline Tool.
You can make the points manually or with the snap button. This also gives you the option to select the nose pixels here.
The outline tolerance controls how closely the generated outline follows the sprite texture.
The Sprite Editor Tools allow you to easily create sprites from sheets and sprite atlases and to simplify the adaptation of the sprites in the engine. It also simplifies the way in which sprites are accessed and used in your project. You can use the tools to make individual adjustments. This also enables you to optimize your workflow by packing sprites into sheets and atlases.
Originally posted on 2019-12-02 20:45:27.