UI Editor/Templates
Templates are a feature of .ui files that allow for a piece of UI to be used as a definition for future pieces of UI, either those created by other UI files or those instantiated by script.
Contents
Local Templates
A local template is the most common type of template. It allows scripts to repeatedly create a hierarchy of components by calling CreateComponentFromTemplate() on any container. A common use for this is for displaying a set of similar items which are not known to the script creator beforehand: browsing a store, checking your inventory, etc.
Global Templates
A global template provides a common template that can be used among several packages to establish a shared look. The most obvious example of this is the CoreUI package which establishes templates for all types of components and windows. A common template functions like a local template, but exists within the shared namespace so other packages can reference it (and will replace other global templates with the same name).
Workflow
Creating a Template
To create a local template named "MyTemplate", follow these steps:
- Create one or more components in your script package with one of them as the root of the others
- Configure them with the Inspector to how you expect them to appear when in use
- Rename the root component of the template in the Inspector to the name you want it for the template ("MyTemplate")
- Right-click the root component and select "Template > Create Local"
- (Optional) Delete the existing item from the hierarchy
The template can then be recreated at any time by right-clicking in the Hierarchy and choosing "Create > Templates > MyTemplate"
Updating a Template
To make changes to the above example "MyTemplate", follow these steps:
- Right-click in the Hierarchy and choose "Create > Templates > MyTemplate"
- Use the Inspector and Hierarchy to make any changes you want to that template or its children
- Right-click the root node of the template in the Hierarchy ("MyTemplate") and select "Template > Update Local"
- (Optional) Delete the existing item from the hierarchy
Deleting a Template
- Expand the Template hierarchy in the Definition Panel to find the template you are looking for
- Select the template you want to delete
- Click the "Delete" button that appears