Node Copied to Clipboard!

Templates


When there are some common processes in a lesson, we can compose them into a template and reuse it as just a single item which will hugely enhance the efficiency and readability of your lesson.

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.

Creating Templates

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.

The template name should be added to the Namespaces tab.

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.

Extracting Template

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.

Using A Template

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.

Editing A Template

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.

Adding Variables To A Template

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.

We can see the Begin node adds an empty slot.

Before we perform the following operations please ensure that you are in Expert mode. If you are not in Expert mode, you can switch to it via the dropdown complexity bar in the Home Menu.

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.

We should get an unnamed light yellow node. Let's rename it to Shape2 in Properties tab.

Now drag the combined node to the slot in Begin node.

The shape2 variable is ready to use. Right-click on empty space of Storyboarder and follow the selection: Variables>>Item2.

We should get a white node called shape2. And we can add animations based on it, just like the first item. Now we create two new animations to control the Shape2 variable.

Step back to the main Storyboarder. As we can see, the old template node still has only one parameter. Right-click on the template node and choose Update Parameters.

The template node should be updated and has two parameter slots with one filled and the second one waiting for us to assign an object to it.

Drag the cube from Edit View to the empty slot.

Run the lesson by clicking Play button and we will find that the cube is animated after the sphere as dictated by the template.

Namespaces

Namespaces allow you to share templates in different lessons under the same project.

Moving an existing lesson template to a Namespace

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.

Name the Namespace and click OK. A Namespace should be added to the Namespace tab.

Drag the 'AnimateShape' template from the Lesson Namespace to the newly created Namespace 'SharedTemplates'.

Since the Namespace of the template has changed, Editor expects a specific path to identify where the template comes from. Right-click on the Storyboarder and type the name of the new Namespace, 'SharedTemplates' in this case. Choose the corresponding selection of the right-click menu and a new node named after the new Namespace will be added to the Storyboarder.

Link the Namespace node 'ShareTemplates' to the top of the original template node 'AnimateShape' and simulate. The template will be working as well as before and you will be able to use this template in any other lessons under the same project.

Note that after moving the template to the new Namespace, if you drag the template to Storyboarder again, Editor will automatically attach the group node to the template node. Right-click on the template node and choose Update Parameters, so that the template's parameters can work correctly.

Creating A New Shared Template

Create a Namespace by right-clicking on empty area of Namespaces tab and choose Add > Namespace.

Name the Namespace and click OK.

Right-click on the newly added Namespace and choose Add > New Template. Name the template and click OK.

A new template should be added to the template group.

Double-click on the new template and you will step into the template node for further edits.