Unity3D: Edit Properties

Recommended: Add NSDT Scene Editor to your 3D toolchain
3D Toolset: NSDT Jane Stone Digital Twins

edit properties

Properties are settings and options for game object components and resources. Properties can be edited in the Inspector window.

Light component showing various value and reference properties

Properties are grouped into the following main categories:

  • References: Links to other game objects and resources.
  • Values: numbers, colors, on/off settings, text, etc.

quote

Reference properties take as input a compatible project asset or game object in the scene. For example, a Mesh Filter component references a Mesh resource somewhere in the project.

When the component was created, its reference property was not assigned.

References can be assigned to properties by dragging and dropping objects and resources into the reference property field, or by using the Object Picker window.

Some reference properties accept specific types of components (for example, transition components). When assigning a GameObject to these properties, Unity will find the first component of the desired type on the GameObject and assign it to the referenced property. If the game object does not have any components with the correct type, the game object cannot be assigned to a property.

Assign references via drag and drop

To assign a reference to a property, drag and drop a compatible game object or asset onto the property field in the Inspector.

Assign references using the Object Picker window

Use the Object Picker window to find and select the reference object to assign.

  1. Click the small circle icon to the right of the property in the Inspector to open the Object Picker window.
  2. Find the object or resource you want to reference, and double-click it to assign it to the property.

value

Most value properties can be edited using simple controls. For example:

Fields in which text and numeric values ​​can be entered.

You can type a value directly into the attribute field, or click and drag the attribute label to increase or decrease the value.

Some properties also have sliders for adjusting the value .

Checkbox , where the property can be toggled on and off.

Dropdown lists and popups where one of several possible values ​​can be selected.

numeric field expression

Numeric field input controls also accept mathematical expressions, such as the input field will result in a value. about which expressions are supported.2+35

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

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


Entering in the X coordinate  L(-6,6) will distribute the ten selected capsules between –6 and 6.ab

  • R(a,b)results in a random value between and .


Entering in the Z coordinate  R(-2,2) will set the selected capsule's Z coordinate to a random value between –2 and 2.ab

  • +=,,,, expressions can be used to modify the current value, for example, enter twice the value of all fields.


Entering  in Z coordinates  will scale all Z coordinates by a factor of 3./=3-=*=/=*=2

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


will  cos(L(0,2*pi))*5 be entered into the X and sin( L(0,2*pi))*5 into the Z coordinates, placing the ten selected capsules in a circle.L(0,2*pi)

When writing custom inspectors, all EditorGUI.PropertyField and EditorGUILayout.PropertyField controls automatically get a logarithmic value expression.

Certain game objects and assets have more complex properties that can be edited using specialized controls or dedicated editors. The remainder of this section describes how to set these complex properties.

color value

The Inspector window displays color attributes as swatches.

Clicking on any swatch opens the Color Picker or the HDR Color Picker (depending on the context). For example, when editing the emission color attribute in the Standard shader , Unity displays the HDR color picker window.

Unity color picker window (left) and HDR color picker (right)

You can also use the eyedropper tool to pick a color value from anywhere on the screen.

To pick a color, click the eyedropper button next to the color property, then click anywhere on the screen. Unity will set the color property to the color of the clicked pixel.

Set colors can be saved in a library of reusable swatches that can be shared between projects.

hint:
On macOS, there is an option to use the system color picker instead of Unity's built-in color picker. Open the General panel via  Preferences (menu: Unity > Preferences) and select macOS Color Picker.

gradient value

A gradient is a visual representation of a color progression. They can be used to gradually blend one color into another in space or time.

In Unity, some gradients can be set by setting two or more color properties.

Other gradients provide dedicated editors to control the relative amount of each color.

Particle System Gradient Editor

The dedicated gradient editor displays the main colors (called _stops_) and all intermediate colors (1) between them in a gradient bar.

Up arrows along the bottom of the gradient bar indicate color stops (2).

  • Click a stop to select it. Unity displays its color value in  the Color field .
  • Click the color swatch (3) to edit the color using the standard color picker.
  • You can also use the eyedropper tool (4) to pick a color value from anywhere on the screen. Click the eyedropper button, then click anywhere on the screen. Unity will set the color property to the color of the clicked pixel.
  • Click in the empty space below the gradient bar to add a stop.
  • Click and drag a stop to move it.
  • To delete a dock, select it and use  the Ctrl/Cmd + Delete  shortcut.

A down arrow above the gradient bar indicates an alpha stop (5) that controls the transparency of the gradient at a given point. Alpha stops can be added and edited in the same way as color stops. When an alpha stop is selected, the gradient editor shows  the Alpha  slider instead of  the Color  field.

By default, gradients have two stops set to 100% alpha (which makes the gradient fully opaque). The stops can be edited to adjust transparency and add other stops as needed.

curve

A __curve__ is a line graph that shows the response (on the y-axis) to a changing value of the input (on the x-axis).

Curve Editor in the Animation Window

Unity uses curves in a variety of different contexts, especially in animation. The Curve Editor has many different options and tools. For more information, see Editing Curves.

bar slider

A bar slider is a specialized control that can be used to visually allocate specific resources. For example, the LOD Group component uses bar sliders to define transitions between Game Object LOD levels.

The LOD Group selection bar is a bar slider control

The relative value of each segment in the selection bar can be adjusted by dragging the segment edges. Some bar sliders also have draggable handles.

array

When a script exposes an array as a public variable, the Inspector displays a control that can be used to edit the number of items in the array ( Size ) and the value or reference within it.

Script with Vector3 array property

When reducing  the Size  value, Unity removes values ​​from the end of the array. When increasing  the Size  value, Unity will copy the current last value to all new elements added.

hint:
To set up an array with essentially the same values, add the first element, then resize to copy its value to subsequent elements.

Create a sample library

Use the swatch library to reuse, save, and share colors, gradients, and animation curves. Samples can be saved and selected in the Color Picker, Gradient Editor, and Curve Editor.

The Swatches section of the Unity color picker

A sample library is a collection of samples saved in a file. The Swatches section displays one sample library at a time.

To save a sample, do the following:

  1. Open the Color Picker, Gradient Editor, or Curve Editor. For example, select Main Camera in the Hierarchy window  .
  2. In the Inspector window, click  Background Color .
  3. In the color picker window, adjust the colors, gradients, or curves to your liking.
  4. In  Swatches  , click the outline box.
  5. If the view is in List mode, there is an option to enter the name of the sample.

Example of saving colors in Grid view

Drag and drop samples to change their order. Right-click a sample to move it to the top, replace it, rename it, or delete it. You can also delete samples by Alt/Option-clicking them.

Use   the dropdown menu in Swatches :

  • Select  List  or  Grid  to change the view. The List view also displays the names of the samples.
  • Choose a sample library.
  • Select  Create a Library  to create a new sample library and a location to save it.
  • Select  Reveal Current Library Location  to view the current library in Windows Explorer/Mac OS Finder.

By default, Unity saves sample libraries in User Preferences. Sample libraries can also be saved within a project. Unity saves the project sample library in  the Editor  folder of the Assets  folder  . To share project sample libraries among users, or to include sample libraries in resource bundles, add them to the revision control repository.

To edit a project sample library:

  1. Select the sample library in the Project window.
  2. In the Inspector window, click  Edit .

  • Reorganized Inspector section pages in Unity 2020.1

This article is organized and translated by 3D Modeling Learning Studio , please indicate the source for reprinting!

Previous: Unity3D: Exclusive Inspector (mvrlink.com)

Next: Unity3D: Toolbar (mvrlink.com)

Guess you like

Origin blog.csdn.net/ygtu2018/article/details/131470199