Version: 2020.1
Sprite Creator
Sprite Editor:Custom Outline

Sprite Editor

Sometimes a Sprite Texture contains just a single graphic element but it is often more convenient to combine several related graphics together into a single image. For example, the image could contain component parts of a single character, as with a car whose wheels move independently of the body. Unity makes it easy to extract elements from a composite image by providing a Sprite Editor for the purpose.

Note: Make sure the graphic you want to edit has its Texture Type set to Sprite (2D and UI). For information on importing and setting up Sprites, see Sprites.

Sprite Textures with multiple elements need the Sprite Mode to be set to Multiple in the Inspector. (Texture Import Inspector image below.)

打开 Sprite Editor

要打开 __Sprite Editor__,请执行以下操作:

1.从 Project 视图(图 1:Project 视图)中选择要编辑的 2D 图像。

Note that you can't edit a Sprite by selecting it in the __Scene View__.

2.单击 Texture Import Inspector(图 2:Texture Import Inspector)中的 Sprite Editor 按钮,随后将显示 Sprite Editor(图 3:Sprite Editor)

注意:仅当所选图像上的 Texture Type 设置为 Sprite (2D and UI) 时,才能看到 Sprite Editor 按钮。

Project View
Project View
Texture Import Inspector with Sprite Editor button
Texture Import Inspector with Sprite Editor button

注意:如果图像具有多个元素,应在 Texture Import Inspector 中将 Sprite Mode 设置为 Multiple

Sprite Editor
Sprite Editor

Along with the composite image, you will see a number of controls in the bar at the top of the window. The slider at the top right controls the zoom, while the color bar button to its left chooses whether you view the image itself or its alpha levels. The right-most slider controls the pixelation (mipmap) of the Texture. Moving the slider to the left reduces the resolution of the Sprite Texture. The most important control is the Slice menu at the top left, which gives you options for separating the elements of the image automatically. Finally, the Apply and Revert buttons allow you to keep or discard any changes you have made.

使用编辑器

使用编辑器的最直接方式是手动识别元素。如果单击图像,则会一个矩形选择区域,该区域的四个角有控制柄。通过拖动矩形的控制柄或边缘可以围绕特定元素调整矩形大小。在隔离一个元素后,可通过在图像的单独部分中拖拽出一个新矩形来添加另一个元素。您会注意到,当选择了一个矩形时,窗口右下角会出现一个面板:

The controls in the panel let you choose a name for the Sprite graphic and set the position and size of the rectangle by its coordinates. A border width, for left, top, right and bottom can be specified in pixels. The borders are useful when 9-Slicing Sprites. There are also settings for the Sprite’s pivot, which Unity uses as the coordinate origin and main “anchor point” of the graphic. You can choose from a number of default rectangle-relative positions (eg, Center, Top Right, etc) or use custom coordinates.

Slice 菜单项旁边的 Trim 按钮用于调整矩形的大小,使矩形基于透明度紧紧围绕着图形边缘。

注意:仅 UI 系统支持边框,而 2D SpriteRenderer 不支持边框。

自动切片

Isolating the Sprite rectangles manually works well but in many cases, Unity can save you work by detecting the graphic elements and extracting them for you automatically. If you click on the Slice menu in the control bar, you will see this panel:

With the slicing type set to Automatic, the editor will attempt to guess the boundaries of Sprite elements by transparency. You can set a default pivot for each identified Sprite. The Method menu lets you choose how to deal with existing selections in the window. The Delete existing option will simply replace whatever is already selected, Smart will attempt to create new rectangles while retaining or adjusting existing ones, and Safe will add new rectangles without changing anything already in place.

Grid by Cell Size or Grid by Cell Count options are also available for the slicing type. This is very useful when the Sprites have already been laid out in a regular pattern during creation:

The Pixel Size values determine the height and width of the tiles in pixels. If you chose grid by cell count, Column & Row determines the number of columns and rows used for slicing. You can also use the Offset values to shift the grid position from the top-left of the image and the Padding values to inset the Sprite rectangles slightly from the grid. The Pivot can be set with one of nine preset locations or a Custom Pivot location can be set.

Note that after any of the automatic slicing methods has been used, the generated rectangles can still be edited manually. You can let Unity handle the rough definition of the Sprite boundaries and pivots and then do any necessary fine tuning yourself.

多边形大小调整

打开多边形的 __Sprite Editor__,其中提供了更改多边形的形状、大小和轴心位置的选项。

Polygon shape

Sprite Editor:多边形大小调整 - 形状
Sprite Editor:多边形大小调整 - 形状

Sides 字段中输入所需的多边形边数,然后单击 Change

Polygon size and pivot

Sprite Editor:多边形大小调整 - 大小和轴心点 - 单击多变形来显示这些选项
Sprite Editor:多边形大小调整 - 大小和轴心点 - 单击多变形来显示这些选项

Polygon size

To change the polygon’s size, click on the Sprite to display green border lines and the Sprite information box. Click and drag on the green lines to create the border you want, and the values in the Border fields change.

Polygon pivot

To change the polygon’s pivot point (that is the axis point the polygon moves around), click on the image to display the Sprite information box. Click on the Pivot drop down menu and select an option. This displays a blue pivot circle on the polygon; its location depends on the pivot option to you have selected. If you want to change it further, select Custom Pivot and click and drag on the blue pivot circle to position it.

Sprite Creator
Sprite Editor:Custom Outline