Version: 2022.3

# 编辑属性

• 引用：到其他游戏对象和资源的链接。
• 值：数字、颜色、开/关设置、文本等。

## 引用

### 使用 Object Picker 窗口分配引用

1. 单击 Inspector 中属性右侧的小圆圈图标，以打开 Object Picker 窗口。
2. 找到要引用的对象或资源，然后双击以将它分配给属性。

## 值

### Numeric field expressions

Numeric field input controls also accept mathematical expressions, for example entering `2+3` into a field will result in value `5`. See ExpressionEvaluator C# class documentation for details on which expressions are supported.

Numeric fields also support special functions that are useful when editing multiple selected objects at once:

• `L(a,b)` results in linear ramp between `a` and `b`.

Entering `L(-6,6)` into X coordinate distributes the ten selected capsules between –6 and 6.
• `R(a,b)` results in a random value between `a` and `b`.

Entering `R(-2,2)` into Z coordinate sets the Z coordinate of the selected capsules to a random value between –2 and 2.
• `+=`, `-=`, `*=`, `/=` expressions can be used to modify the current value, for example entering `*=2` makes all the the field value twice as large.

Entering `/=3` into Z coordinate makes all Z coordinates 3x smaller.

You can combine math expressions. For example, you could use the expression, `L(0,2*pi)`, which produces a linear distribution of values between 0 and 2pi radians, as the argument of a trigonometric function. To illustrate, the following example uses this linear ramp function as the argument to sine and cosine functions in order to distribute a set of selected objects in a circle:

Entering `cos(L(0,2*pi))*5` into X and `sin(L(0,2*pi))*5` into Z coordinates places the ten selected capsules in a circle.

When writing custom inspectors, all EditorGUI.PropertyField and EditorGUILayout.PropertyField controls automatically get support for the numeric expressions.

### 颜色值

Inspector 窗口将颜色属性显示为样本。

### 渐变值

In Unity, gradient values are used by the particle system, line renderer and a few other components. You can also have public Gradient class variables in your C# scripts, and the inspector will display a gradient editor for them.

The gradient editor shows the main colors, called keys, and all the intermediate shades between them in the gradient bar (1).

Upward-pointing arrows along the bottom of the gradient bar represent color keys (2).

• Click a key to select it. Unity displays its color value in the Color field.
• 单击颜色样本 (3) 可使用标准拾色器编辑颜色。
• 还可以使用吸管工具 (4) 从屏幕上的任何位置选取颜色值。单击吸管按钮，然后单击屏幕上的任何位置。Unity 会将颜色属性设置为单击的像素的颜色。
• Click an empty area under the gradient bar to add a key.
• Click and drag a key to move it.
• To delete a key, select it and use the Ctrl/Cmd + Delete shortcut.

Downward-pointing arrows above the gradient bar represent alpha keys (5) that control the gradient’s transparency at a given point. You add and edit alpha keys the same way you edit color keys. When you select an alpha key, the gradient editor displays an Alpha slider instead of the Color field.

By default, a gradient has two keys set to 100% alpha, which makes the gradient fully opaque. You can edit a key to adjust the transparency, and add additional keys as needed.

A gradient can use several different color interpolation modes:

• Blend mode linearly interpolates between the color keys.
• Blend (Perceptual) mode interpolates between the color keys using a perceptually uniform “Oklab” color space.
• Fixed mode does not interpolate the colors; the value of the color or alpha key is used until the next key.

### 曲线

__曲线__是一个线形图，显示对输入变化值（在 x 轴上）的响应（在 y 轴上）。

Unity 在各种不同的上下文中使用曲线，尤其是在动画中。曲线编辑器具有许多不同的选项和工具。有关详细信息，请参阅编辑曲线

## 创建样本库

1. 打开拾色器、渐变编辑器或曲线编辑器。例如，在 Hierarchy 窗口中选择 Main Camera
2. Inspector 窗口中，单击 Background Color
3. 在拾色器窗口中，根据喜好调整颜色、渐变或曲线。
4. Swatches 中，单击轮廓框。
5. 如果视图处于 List 模式，则可以选择输入样本的名称。

• 选择 ListGrid 来更改视图。List 视图还显示样本的名称。
• 选择一个样本库。
• 选择 Create a Library 可创建新的样本库以及保存该样本库的位置。
• 选择 Reveal Current Library Location 可在 Windows 资源管理器/Mac OS Finder 中查看当前库。

1. Project 窗口中选择样本库。
2. Inspector 窗口中，单击 Edit

• 在 Unity 2020.1 中重新组织了 Inspector 部分页面