Templates are useful if, for example, we want to animate several different shapes in the same manner. In this case, we don't need to perform every step again and again. All we need to do is to copy the template and give the template a new reference that we want to apply in the template.
Templates are created in the Namespaces Tab. They can be created right under the Main lesson or under a new namespace.
We use namespaces to group together related variables and templates.For now, we will create a general template by right-clicking on Lesson in the Namespaces tab and clicking add > Template
Name your template and click add.
Double click the template name. This brings you to a new storyboarder that starts with a single begin node. You will build your template off of this node.
Click the plus button on the begin node to add a parameter to your template.
Make sure to give your parameter a type and a variable associated with it. You will reference the variable in order to manipulate it in your template.
In the following example, SceneModel is the type and Shape is the variable which will be animated in two different ways.
You can also create a template by extracting nodes straight from the storyboarder.
Identify the nodes or process you want to transform to a template.
Click on empty space in Storyboarder and move the cursor to cover the nodes you want to form a template with, just like we select multiple files in Windows.
If you expect the template to apply to different items in the future, you do not need to select the object(s) that your nodes manipulate.
As the picture shows, we use two Animate nodes to control the cone. We only need to select these two Animate nodes and all the lines involved and leave the cone unselected. All the selected items will be highlighted by black lines.
Right-click on any selected item and click Extract Template in the right-click menu.
An Extract Template dialogue will pop up and you can name the template. Meanwhile the editor identifies that this template is trying to manipulate an object(Cone) and treats it as a reference to the template, and you can rename the reference as well. After renaming click OK.
Now we get a one piece node with the reference object(Cone) in it.
We should find a newly created template in the Namespaces tab as well.
Click and drag the template from Templates tab to Storyboarder.
A new corresponding template node should show in the Storyboarder.
As we can see, the template node named AnimateShape is expecting a reference that it can manipulate.
Drag an object from the Editor Window or Scene Hierarchy and put it into the template parameter slot which is named 'Shape' in this case.
Link the new template node next to the former one and click Play button, we will see the Sphere animated exactly like the cone.
We can also edit a template by double click the template node or the template name in Namespaces tab.
After double clicking, we will step into the template and we can edit it properly.
Now we can modify the template to be able to control two items.
Double click the template in the Namespaces tab to step into the node for further editing.
We can add variables via the Begin node. There is a small + sign at the bottom left of the node. Click the + sign.
Right-click on empty space of Storyboarder and follow the selection: Type > Scene > Model.
We should get a dark node called SceneModel. This node declares what type the new variable is.
Click on bottom handle of SceneModel(type) and select create variable.
Namespaces allow you to share templates in different lessons under the same project.
Given that we already have an existing template called 'AnimateShape' in the Lesson Namespace.Create a new Namespace by right-clicking on empty area of Namespaces tab and choose Add > Namespace.
Create a Namespace by right-clicking on empty area of Namespaces tab and choose Add > Namespace.
Click to download the sample asset used in demonstration.