You can instantiate existing UXML documents as templates inside another UXML document, similar to PrefabsAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. More info
See in Glossary. In the Hierarchy window, a template appears as a template instance of type TemplateContainer.
To instantiate an existing UXML document:
.uxml asset.A Template Instance appears in the Hierarchy window. Unity shows the source file name in grey beside the instance name. Expand the instance to view its internal hierarchy for reference. The internal hierarchy is read-only in the parent document.
To save an existing element and its children as a new UXML template:
.uxml file.Unity exports the element and its children to the new file and replaces the original element with a Template Instance that references it. This action isn’t fully reversible: Undo restores the element in the hierarchy but doesn’t delete the created .uxml file.
Unpacking replaces a Template Instance with the child elements from the template placed directly in the parent document. Unity preserves inline attributes and child attribute overrides.
To unpack a template instance:
To edit the UXML used by a template instance, right-click (macOS: Ctrl+click) the instance in the Hierarchy window and select one of the following:
When you edit in context or isolation, a breadcrumb bar appears in the UI Viewport window. Use it to navigate back to parent documents.
You can also open a template from the Inspector window header when you select a Template Instance.