[Unity] 2.7 Inspector and unityinspector

Source: Internet
Author: User

[Unity] 2.7 Inspector and unityinspector

Classification: Unity, C #, VS2015

Created on: 1. Introduction

Games in Unity are multiple game objects (GameObjects) that contain mesh, script, sound, light, and other graphic elements. The Inspector displays the details of the currently selected game object (GameObjects), including all the additional Components and their attributes.

The Inspector view is used to display the details of the currently selected objects in the game scenario, as well as the overall attribute settings of the game, including the object name, Tag, Location Coordinate, rotation angle, scaling, component, and other information.

In the Inspector view, each component has the corresponding help button and context menu ]:

Click the Help button (question mark icon) to display the component-related documents in the user manual installed on the local machine.

Click context menu to display the options related to this component. You can also select the Reset command from the drop-down menu to Reset the property value to the default value.

  • Transform: You can use the Transform component to modify the position, rotation, and scaling attributes of an object.
  • Mesh Filter: A Mesh Filter Used to obtain Mesh information from an object and transmit it to the Mesh Renderer.
  • Box Collider: Cube collision body. To prevent objects from being penetrated, you must add a collision body to the object. Generally, the distance of an object is calculated based on coordinates, and then the collision is determined.
  • Mesh Renderer: The Mesh Renderer obtains the geometric shape from the Mesh Filter and renders it based on the defined position of the Transform component of the game object.
  • Cast Shadow: whether to Cast a Shadow on a grid.
  • Receive Shadows: whether the grid receives shadow.
  • Materials: Specifies the material of an object.

When you create a script, it serves as a custom Component. When this script Component is added to a game object (GameObject, the member variables of the script are displayed as directly editable Properties in the Inspector. In this way, you can change the variable without modifying the script itself.

In addition, Inspector is used to display import options for resources, such as textures, 3D models, and fonts selected. Settings for certain scenarios and project scopes can also be viewed in the Inspector, for example, all Settings Managers ).

Any attribute displayed in the Inspector can be directly modified. There are two main types of attributes: Value and References ). The value may be the color or vector of the light source. References are links to other objects, such as textures or other game objects.

1. Edit value Attributes

The value attribute cannot reference any content and can be edited directly. Typical value attributes include numbers, switches, strings, and selection pop-up windows. They can also be colors, vectors, curves, and other types.

The value Attributes on the viewer can be numbers, check boxes, strings...

Many value attributes have a text field. You can click them, Enter a value on the keyboard, and press Enter to save the value.

You can also move the cursor to the value attribute and drag it with the left button to scroll the value quickly.

Some numeric attributes have a slider that can be used to intuitively adjust the value.

Some value properties will pop up a small dialog box that can be used to edit the value.

(1) color picker

Color Picker is enabled for the Color type attribute ). To search for a value, place the mouse over the color to be captured, and then use the Eyedropper Tool ). The \ RGB/HSV selector allows you to convert values of red, green, and blue to colors, colors, saturation, and values (intensity ).

Finally, the transparency of the selected color can be controlled through the Alpha Channel value.

(2) Curve Editor)

The property of the animation Curve type opens the Curve Editor ). The Curve Editor allows you to edit a Curve or select a preset one.

Due to the old version, this type is called an animation curve, but it can be used to define any custom curve function. This function can be evaluated when the script is running. The animation curve property is displayed as a small preview in the viewer:

Click it to open the Curve Editor ):

The Curve Editor is used to edit animation curves ).

Wrapping Mode allows you to select the Ping Pong, Clamp, and Loop control keys in the curve.

Presets allows you to change a curve to its default profile.

(3) gradient Editor

In Graphics and animations, it is very useful to mix one color into another from space or time. A gradient is an intuitive representation of color changes. It only displays the major colors (called the start and end colors) and all the critical tones between them. In Unity, the gradient has its own special value Editor, as shown below.

The top arrow at the bottom of the gradient bar indicates the starting and ending colors. Click it to select a start and end color. Its value is displayed in the color box. When you click it, the standard color selector is displayed. Click below the gradient bar to create a new start and end color. Click and drag to change the position of any start and end colors. Press ctrl/cmd + delete to delete a start and end color.

The lower arrow at the top of the gradient bar is also the starting and ending color, but they correspond to the alpha (transparency) of the gradient. By default, two starting and ending colors are set to 100% alpha (completely opaque), but any number of starting and ending colors are roughly the same as the adding and editing methods of the color's starting and ending points.

(4) array

The script you write can arrange the original. Net array in the Inspector. When the Inspector encounters an array, it allows you to edit the length of the array. The default length is zero. When the size is set to greater than zero, the Inspector creates a slot. You can enter the value of an array element in the slot. If the array stores data of known types of Unity, it inserts a suitable value editor. For example:

Var pickupColors: Color32 [];

A color selector editor is generated for each element in the array.

2. Specify the reference

A reference property is a property that can reference other objects, such as game objects, Components, or resources ). The reference slot displays the object types that can be used for the reference. For example, the Audio Clip (Audio Clip) attribute slot shows the Audio Clip (Audio Clip) class objects that can be referenced by it:

Currently, an Audio Clip (Audio Clip) file is referenced in the Audio Clip attribute.

Class references are fast and powerful, especially when using scripts.

(1) drag and drop

You can drag and drop objects or use the Object Picker to assign objects to the reference attributes.

You can select the desired object in the scenario View, Hierarchy, or Project View, and drag it to the reference attribute slot to complete drag and drop.

If a reference property accepts a special Component type (for example, Transform), the game object or Prefab) dragging to the reference property can also work well if the game object (GameObject) or preset (Prefab) contains the right type of components. Although this is a game object (GameObject) or preset (Prefab) that you drag, the property will still reference this component.

If you drag an object to the reference property, and the object is of an error type or does not contain the correct component, you cannot specify this object for the reference property.

(2) object Selector

You can click the Small Target icon next to the reference slot to open the Object Picker ).

Object Picker is a simple window that allows you to assign these objects in the viewer After previewing and searching for available objects.

Although Object Picker is easy to use, you should also understand the following instructions. Is the Interface Description of the Object Picker:

  • Search: When the selector contains many objects, you can use the "Search" field for filtering. This "Search" field can also use tags to search for objects.
  • View selector: switches the search libraries of objects in scenarios and resources.
  • Preview size: This horizontal scroll bar allows you to increase/decrease the preview object size in the preview window. With this scroll bar, you can view more or fewer objects in the preview window at any time.
  • Preview window: all objects in the "scenario/resource" folder filtered out by the "Search" field.
  • Object Information: displays the information of the currently selected object. The content of this field depends on the type of the object to be viewed. For example, if you select a grid, it will tell you the number of vertices and triangles, whether there is UV, and whether there is skin. However, if you select an audio file, it will provide you with information such as the audio bit rate and length.
  • Object preview: this also depends on the object type you are viewing. If you select a grid, it will show you the appearance of the grid, but if you select a script file, it will only show the file icon.

The Object Picker can work on any resources of the project (such as videos, songs, terrain, GUI skin, script files, or grids; it is a frequently used tool.

Tip: using tags on resources (Assets) makes it easier for you to find them than using Object Picker to search for fields.

If you do not want to see the object description, you can drag down the slider in the middle of the preview window.

If you want to see the detailed preview of an object, you can drag the slider in the middle of the preview window to enlarge the object preview.

3. multi-object editing

You can select and edit multiple objects of the same type in the Inspector. Any changed attributes will be applied to all selected objects. If you want to make the same changes to many objects, this saves a lot of time.

When multiple objects are selected, only components that exist in all selected objects are displayed in the Inspector. If a component only exists in some selected objects, a small prompt will appear at the bottom of the Inspector, indicating that the components that exist only in some selected objects cannot be edited multiple times.

(1) attribute values

After multiple objects are selected, each attribute displayed in the Inspector view represents the attributes of each selected object. If the property values of all objects are the same, the value is displayed normally, just like editing a single object. If the attribute values of all selected objects are different, no values are displayed, and dashes or similar symbols are displayed, indicating that these values are different.

(2) edit multiple objects

Whether it is a display value or a short line, the attribute value can be edited as usual, and the modified value will be applied to all selected objects. If the values are different and the dashes are displayed, you can still right-click the attribute tag. This will bring up a menu so that you can choose from which object to inherit the property value.

(3) Multi-edit presets or model instances

Like Game Objects, presets can be edited multiple times in the scene. Instances of presets or models can also be edited in multiple ways. However, there are also some restrictions: When you edit a single preset or model instance, any attributes different from the preset or model will be displayed in bold, right-click an option to restore the attribute to its value in the preset or model. In addition, Game objects have options to apply or restore all changes. These operations are not available when you edit multiple objects. Properties cannot be restored or applied; they are not displayed in bold even if they are different from the preset or model. You must be reminded that the Inspector will prompt that the instance management is invalid, and "Select", "Restore", and "Apply) "button usually appears.

Invalid instance management for preset multiple edits

(4) unsupported objects

A few object types do not support multi-object editing. When multiple objects are selected at the same time, these objects are displayed with a prompt saying "multi-object editing is not supported ".

When you use the custom editor to edit your script, this message is displayed if it does not support multi-object editing. See the editor Script Reference to learn how to support multi-object editing in your custom editor. Ii. Viewer options

"Viewer lock" and "Viewer debugging mode" are two useful options that can help you in the workflow.

1. Lock

Lock allows you to focus on a specific game object (GameObject) in the Inspector When selecting other game objects. To switch the lock option of the Inspector, click the lock/unlock () icon on the Inspector, or open the tab menu and select lock.

Click the tab menu to lock the Inspector ).

Note that you can open more than one Inspector at the same time, lock the viewer of a specific game object, and keep the other unlocked, to display the selected game object (GameObject ).

2. debugging

Debug Mode allows you to check private variables of a component in the Inspector, which is usually not displayed. To change to Debug Mode, open the tab menu and select Debug.

In Debug Mode, all components are displayed on the default Interface instead of the custom interface used by some components in Normal Mode. For example, the Transform component displays the rotated Quaternion values in Debug Mode instead of the Euler's angles in Normal Mode ). You can also use Debug Mode to check the values of private variables in your script component.

Debug Mode in Inspector allows you to check private variables in scripts and other components.

Each Inspector has a debugging Mode. You can enable an Inspector to work in Debug Mode, but not the other.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.