Inheritance
Inheritance describes relationships where child objects inherit values from an original parent object, and where child objects can override inherited values.
Inheritance describes relationships where child objects inherit values from an original parent object, and where child objects can override inherited values.
Inheritance offers several advantages over individually setting values for each object:
An object is an entity or asset defined using specific properties.
Examples of objects in the Editor include:
A property is an object parameter that stores a value. The property definition should designate the specific type of value the property can store.
Examples of properties include:
Inheritance is a relationship between a parent object and its child objects.
A parent object defines specific properties and values, from which child objects will derive their values; if the parent object’s values change, the child objects will reflect those changes.
An instance of an object is a single occurrence of an original object and, in the context of inheritance, refers to child objects that inherit properties and values from its parent.
Instances are a reference to the parent object, and may be stored in, or “live" in, a different place than the parent objects. For example, while Prefab objects are stored in the Project, Prefab instances are stored in the Hierarchy of the Scene.
At the value level:
At the object level:
Inheritance relationships are typically manipulated and managed at the object level.
Creating an inheritance relationship
Parent objects are usually stored as assets in the Unity project.
There are typically two ways that parent objects can be created:
Deleting an inheritance relationship is known as detaching:
It is possible for multiple levels of inheritance to exist. One type of multi-level inheritance is variants.
An override is when a value set on a child object prevails over and replaces a value inherited from a parent. Overrides are primarily an authoring-time feature.
Overrides represent a specific inheritance concept in the Editor, and is expressed through a specific set of UI and UX features.
Do not use override UI patterns in features that do not make use of the conceptual model of overrides and inheritance as defined above.
What is not an override:
In the Editor, an override is signified at the value level using the override bar.
-> see the Anatomy & UI section
It is important to preserve the meaning of the override bar, as users associate it with a specific concept in the Editor and are able to apply that concept in multiple areas, including areas new to them.
Do not use the override pattern just to indicate “this line is different”:
At an object level, provide an aggregate view of all overrides on the object so that the user may work efficiently.
See the Overrides at an object level section ->
At a value level:
At an object level:
A variant
Consider implementing variants in your feature if it will be heavily used by medium- to large-sized production teams, where multiple users with different responsibilities access a single Unity project.
Iconography
Variant assets in Unity are marked with an icon that is a variation of the parent object’s icon. Variants have a distinct, consistent visual language applied to the parent object’s icon.
Inheritance Tree View
Creating variants
Typically, variants are stored the same way as other parent objects: as assets in the Unity project.
There are typically two ways that variants can be created:
Deleting Variant Relationships (Detaching)
You might consider implementing override locking in your feature if your feature will be heavily used by medium- to large-sized production teams, where multiple users with different responsibilities access a single Unity project.
Signifying on parent objects
Show the override locking feature upon hover next to the property that can be locked.
Signifying on instances
The override bar is the visual signifier that denotes the presence of an override on the property.