# Hierarchy and Inheritance
In UNIGINE, materials can form hierarchy. However, there are several rules and constraints that described below and must be taken into account.
## Materials Hierarchy
Materials hierarchy forms by inheriting one material from another. A parent material passes its properties to the inherited material so that they can be overridden.
UNIGINE provides a set of **[base materials](../../content/materials/index.md#base_materials)** with the built-in shaders which are always at the top of the **materials hierarchy**. The base materials cannot be organized in hierarchy: no base material can be inherited from another base material. Moreover, properties of the base materials cannot be changed. So, to modify one of the base materials, you should inherit a **[user material](../../content/materials/index.md)** from it: the base material will pass its properties to the inherited material.
However, not only base materials can be used as parent ones. You can inherit a new material from any user material.
> **Notice:** All inherited and non-overridden properties will be updated automatically, if they are updated in the parent material.
The parent of the material can be changed by dragging the material to a new parent.
In this way, there are the following reasons to create materials hierarchy:
- Inheriting from the base material allows editing its properties via Materials Editor.
- Inheriting from the user material allows for mass controlling values of multiple materials parameters.

*Hierarchy of materials in theMaterials HierarchyWindow*
|  |  |
|---|---|
| *Basemesh_basematerial* | *Child material inherited frommesh_base* |
The material ball on the left picture is rendered using the *[mesh_base](../../content/materials/library/mesh_base/index.md)* base material from the default set of materials. The material ball on the right picture is inherited from *mesh_base* and has 1 texture changed (the [albedo](../../content/materials/library/mesh_base/index.md#texture_albedo) texture). All the other properties are identical to the base material ones.
## Materials Loading Order
Materials hierarchy doesn't affect the loading order of materials: on the engine start-up, all materials of the project are loaded, the base materials are loaded first. And since each user material refers to both the parent and the base materials, the base material is used as the parent one until the actual parent is loaded. So, when the application is loaded, all materials existing in the project are presented in the materials hierarchy.
## Referring Materials by GUIDs
A **GUID** (Globally Unique Identifier) is an identifier for a material. The GUID is a 40-character hexadecimal string generated by using the SHA-1 hash algorithm.
Materials hierarchy is based on GUIDs: all materials are referred by GUIDs, even the base and manual ones (the GUIDs for such materials are generated in run-time by their names).
Only the user materials store their GUIDs explicitly: the GUID is generated automatically on user material creation and is written in the `*.mat` file.
> **Notice:** Each user material created via Material Editor has the GUID.
For example:
```xml
```
The user material GUID is stored in the *guid* attribute. If the user material is inherited from another user material, it will refer the parent by its GUID (the *parent* attribute in the example above).
Using GUIDs makes it difficul to edit the user materials manually. For example, to rename such material, it is required to generate a GUID for the new name and replace the current GUID.
For the base and [manual](../../content/materials/index.md#manual_internal_materials) materials, the GUIDs are generated in run-time by their names. If the name of such material is changed, the GUID will also be changed. That is why the base and manual materials cannot be renamed in run-time. For the same reason, the `*.basemat` and `*.mat` files store their names, not GUIDs. And references to such materials stored in these files are [usually name-based](#inheritance_types) too.
## Types of Inheritance
As it was mentioned above, the user material can be inherited from the base, user or manual user material. Depending on the type of the parent, the `*.mat` file will store the reference to it as follows:
- Parent: *base material*. The `*.mat` file stores a GUID of the user material and a name of the base material. ```xml ```
- Parent: *user material*. The `*.mat` file stores a GUID of the user material, a GUID of the parent material and a name of the base material. ```xml ```
- Parent: *manual user material*.
- If the inherited user material is also manual, the `*.mat` file stores a name of the user material, a name of the parent material and a name of the base material. > **Notice:** Only the manual material can refer to the parent manual material by the name. ```xml ```
- If the inherited user material isn't manual, the `*.mat` file stores a GUID of the user material, a GUID of the parent material (generated in run-time by its name) and a name of the base material. ```xml ```
## Creating a User Material
UNIGINE provides the huge set of built-in base materials to meet practically all user's demands. So, the fastest and the safest way to create a new material is to create a user material by inheriting it from the base one and adjusting its properties.
> **Notice:** The user material created via Materials Editor in run-time cannot be customized: a set of user material properties cannot differ from properties of the parent (base) material.
To inherit a material, perform the following in the *[Materials Editor](../../editor2/materials_settings/index.md)*:
1. Select the base material.
2. Inherit from this material: click the  **Create Child** button or right-click the material and choose **Create Child**.  The new `*.mat` file that stores a GUID of the new material and a reference to the *mesh_base* base material will be created. To rename the material, right-click the material and choose **Rename**: the file will be renamed as well.
3. Enable properties you want to apply to your material in the *States* tab of the inherited material. 
4. Replace default textures with your prepared ones in the *Textures* tab of the inherited material. 
5. Tweak the available parameters in the *Parameters* tab of the inherited material. 
> **Notice:** States, textures and parameters of the base material cannot be changed.