Description
The Global Variable interface asset (IA) enables you to store and access any numeric or text value for the duration of a running experience. It is a simple way to pass a value from one scene to another or to save session information like a user identifier.
Notes
- Each Global Variable IA is reinitialized to its default value (see Properties below) when exiting Play Mode in Composer or restarting an experience in Player.
- To use multiple global variables in the same experience, add multiple instances of the Global Variable IA and then rename each one. Renaming can be done either in the Interface Asset panel directly (select and then either right-click the IA or press the F2 button) or in the Properties panel for a selected IA. See image below for the two options.
Properties, Triggers & Actions
Properties
- Value: the stored value. It can be text or numeric.
Triggers
Global Variable
- Value changed: raised when the value has changed
Comparators
Each of the following triggers are raised when the Output text value has changed and the condition is found to be true
NOTE: Only if Output text is comprised solely of numbers can the number-specific comparators below be used. However, even a string of numbers can be treated like text.
- If treating the Output text value as text
- Output value equals
- Output value does not equal
- Output value contains
- Output value does not contain
- Output value matches
- Output value does not match
- Output value starts with
- Output value does not start with
- Output value ends with
- Output value does not end with
- If treating the Output text value as a number
- Output value is greater than or equal to
- Output value is greater than
- Output value is less than or equal to
- Output value is less than
Actions
- Set Value : save a new value into the variable.
- Clear: empties the variable.
Usage example
Here is a common scenario that is easy to build when using a global variable.
- In your Intro scene, add a Text Input control so the user can enter his/her name.
- Store the value in a Global Variable. You can rename the global variable into something like Logged user.
- In every other scene, display a Text asset bound to this Logged user variable, placed next to a "Disconnect" button that would reset the variable.
Comments
0 comments
Article is closed for comments.