Variables

Introduction

Variables allow modifying built-in properties on objects (such as the position of an entity) or the creation and modification of new properties (such as a character’s max movement speed).

Glue includes three types of variables:

  1. Tunneled variables – variables which can be added to a screen or entity that provide access to a variable of an object contained within the screen or entity
  2. New variables – variables which do not have any built-in functionality, but which are added through Glue and used in custom code
  3. Exposed variables – variables which are available in code but not available (by default) on an entity. Exposed variables expand the available variables on an entity or screen.

Adding a Variable

Variables can be added to Glue screens and entities by following these steps:

  1. Expand an existing screen or entity
  2. Right-click on the Variables folder
  3. Select Add Variable

This will bring up the New Variable window which is used to select the variable type and set options according to the selected variable type.

Expose an existing variable

Exposing an existing variable enables editing a variable which would otherwise only be available in code. The variable dropdown provides a list of available variables for the selected object. Note that this type of variable creation is rarely used.

Tunnel a variable in a contained object

Tunneled variables enable exposing a variable from a contained object to that it is editable at the entity level. For example, consider a Button entity with a TextInstance object.

Buttons often display strings such as “OK” and “Cancel”, so we will want to allow the editing of the TextInstance’s DisplayText property.

The easiest way to tunnel into the TextInstance’s variables is to follow these steps:

  1. Drag+drop the TextInstance onto the Variables folder
  2. Use the dropdown to select DisplayText
  3. Change the name to Text. This is not necessary but in this case Text is easier to understand than TextInstanceDisplayText.
  4. Click OK

Note that variables can be tunneled by right-clicking on the Variables folder, but this drag+drop approach auto-selects the Tunnel a variable in a contained object option, and selects the object in the Object dropdown.

Create a new variable

To add a new variable:

  1. Right-click on the Variables folder
  2. Click the Create a new variable option
  3. Select the type such as float
  4. Enter a name such as MaxSpeed
  5. Click OK