Type and Metadata Programming |
The architecture of the engine allows you to work with object types at an advanced level. You can create complex objects, then use it as types. That gives the ability in a visual manner to create types, create an inheritance of types, attaching nested components to the component hierarchy, adding virtual properties and other features. It's similar to object-oriented programming, but for resources.
A first simple action with types is the ability to save the component hierarchy into a separate file. Use 'Export to File' context menu item to do it. Next, the resource can be used as a type.
Another way it is using resources as containers of types. For example, select your scene file, press '+' to see the objects of the scene.
Find objects by name.
And drop the objects to another scene.
You can add virtual properties and virtual methods to any objects.
Also, event handlers can be used to expand functionality of objects.
The editor allows customizing the hiding of properties and nested objects. This is done using the Type Settings form, which can be opened via clicking the button in the upper right corner of the Settings Window.
Opened form.
On the examples 'Material base.material' and 'Material inheritance.scene' you can see how it works. Files are in 'Assets\Samples\Starter Content\Scenes\Material inheritance'. The example demonstrates the inheritance of materials, the hiding of properties, the use of virtual properties.
The file 'Material base.material' is a material that has the virtual property Color added. All other properties and 'Shader graph' attached object are hidden using the Type Settings form.
The file 'Material inheritance.material' is an example of using the material. As you can see, only the Color property is available. There are no other properties, as there is no nested 'Shader graph'. Along the way, an example demonstrates the possibilities of instancing of materials.