Difference between revisions of "UI Editor/Templates"

From Virtual World Web Wiki
Jump to: navigation, search
(Global Templates)
Line 5: Line 5:
  
 
== Global Templates ==
 
== Global Templates ==
A global template provides a common template that can be used among several packages to establish a shared look. The most example of this is the [[UI Editor/CoreUI|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).
+
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 [[UI Editor/CoreUI|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 ==
 
== Workflow ==

Revision as of 16:49, 29 November 2017

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.

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:

  1. Create one or more components in your script package with one of them as the root of the others
  2. Configure them with the Inspector to how you expect them to appear when in use
  3. Rename the root component of the template in the Inspector to the name you want it for the template ("MyTemplate")
  4. Right-click the root component and select "Template > Create Local"
  5. (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:

  1. Right-click in the Hierarchy and choose "Create > Templates > MyTemplate"
  2. Use the Inspector and Hierarchy to make any changes you want to that template or its children
  3. Right-click the root node of the template in the Hierarchy ("MyTemplate") and select "Template > Update Local"
  4. (Optional) Delete the existing item from the hierarchy

Deleting a Template

  1. Expand the Template hierarchy in the Definition Panel to find the template you are looking for
  2. Select the template you want to delete
  3. Click the "Delete" button that appears