Unity3d level view of the Learning Interface (Hierarchy) (ii)

Source: Internet
Author: User
Tags inheritance
Thanks for the comments and attention, welcome to reprint and share.
Hard work and perseverance.

From Unity3d official website study Document: Http://edu.china.unity3d.com/learning_document in this write oneself also when learning side record, also hope can help everyone.

Hierarchical View (Hierarchy)


Hierarchical View (Hierarchy) contains each game object (gameobject)in the current scene. Some are direct instances of resource files such as three-dimensional models, others are preset (prefabs) instances, and custom objects make up the majority of the game. You can select an object in the hierarchy view (Hierarchy) and drag an object to another object to apply a parent-child ( parenting)(see figure below). After you add and delete objects in the scene, they are also displayed or disappear in the hierarchy view (Hierarchy).


Parent-Child (parenting)

Unity uses the concept of parent-child (parenting) . Make any Game object (Gameobject) A child of another object, and drag the child object that you want to move to the parent object in the hierarchy view (Hierarchy). Child objects inherit the parent object's move and rotation paths. You can click the collapsed arrow of the parent object to show or hide the child objects as needed.


Two non-parented objects


One object is the parent object of another

For more information on parent-child (parenting), browse the conversion components (Transform Component) page.

Presets (prefabs)

Presets (Prefab) is a resource-a reusable game object (gameobject)that is stored in the Project view . Presets (prefabs) can be placed into multiple scenes, and can be used more than once per scene. When you add a preset (Prefab) to a scene, an instance of it is created. All preset (PREFAB) instances are linked to the original preset (Prefab), which is essentially a clone of the original preset. No matter how many instances you have in your project, you will see these changes applied to all instances when you make any changes to the Presets (Prefab).


Create Presets (prefabs)

To create a preset (Prefab), simply drag one of the game objects (Gameobject) you created in the scene into the project view. The name of the game object (Gameobject) turns blue, which shows that this is a preset (Prefab). You can rename the new preset (Prefab).

After you complete these steps, the game object (Gameobject) and all its child objects are copied into the preset (Prefab) data. The preset (Prefab) can now be reused in multiple instances. The original game object (Gameobject) in the Hierarchy view (Hierarchy) has now become an instance of the preset (Prefab).


Presets (Prefab) Example

To create a preset (Prefab) instance in the current scene, drag the preset (Prefab) from the project view into the scene or Hierarchy view (Hierarchy view). The instance is linked to a preset (Prefab), and its name is displayed in blue text in the hierarchy view (Hierarchy).


Three of the game objects (gameobjects) are linked to the preset (prefabs) and the other is not. If you select a preset (Prefab) instance and want to make changes to affect all instances, you can select the source preset by tapping the select button in the viewer (Inspector) ( Prefab). For information about instantiating a preset from a script, see Instantiating a preset page.


Inheritance

Inheritance refers to all the linked game objects (gameobjects) that are applied whenever a source preset (Prefab) change occurs. For example, if you add a new script to a preset (Prefab), all linked game objects (Gameobjects) will also include the script immediately. However, it is possible to change the properties of a single instance while keeping the link intact. Change the properties of any one of the preset instances to see that the variable name becomes bold. The variable is now overridden. All overridden properties are not affected by the source preset (Prefab) change.

This enables you to modify the preset (PREFAB) instances so that they are different from the source preset (prefabs) and do not break the preset (Prefab) links.


There is no overridable variable for a linked game object (Gameobject).


There is a linked game object (Gameobject) that has several overridable variables (names are bold).


If you want to update the source presets (Prefab) and all instances with the new override values, you can click the apply button in the viewer (Inspector). Note that the location and rotation of the root will not be applied because it affects the absolute position of the instance and all instances are placed in the same location. However, the position and rotation of any child elements or ancestor elements of the root are applied, as they are computed relative to the root transformation. If you want to discard all overrides for a particular instance, click the restore (Revert) button.


Import Presets (prefabs)

When you put a grid resource into a resource (Assets) folder, Unity automatically imports the file and generates something similar to the grid preset (Prefab). This is not actually a preset (Prefab), it is just the resource file itself. There are some limitations when instantiating and processing resources that do not occur when working with normal presets (prefabs).


Please note that the resource (asset) icon is slightly different from the preset (Prefab) icon

A resource is an instance of a game object (Gameobject) that exists in the scene, linked to a source resource rather than a normal preset (Prefab). You can add components to and remove components from the game object (Gameobject) normally. However, you cannot make any changes to the resource itself because it adds data to the resource file itself. If you create something you want to reuse, you should make the resource instance a preset (Prefab) in accordance with the steps listed in "Create Preset (prefabs)" above.


When you select a resource instance, the apply button in the viewer (Inspector) is replaced with the to edit the (Edit) button. Clicking this button launches the editing application (such as Maya or Max) for your resource.

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.