Skip to main content
Platform:
Language:

Variables

In this example, we will show you how to use the CreativeEditor SDK's CreativeEngine to modify variables through the variable API. The variable API lets you set or get the contents of variables that exist in your scene.

Setup#

This example uses the headless CreativeEngine. See the Setup article for a detailed guide. To get started right away, you can also access the block API within a running CE.SDK instance via cesdk.engine.block. Check out the APIs Overview to see that illustrated in more detail.

Functions#

  • findAll(): string[] returns the names of all existing variables.
  • setString(name: string, value: string): void lets you set the value of a variable to the given string.
  • getString(name: string): string returns the string value of a variable.
  • remove(name: string): void removes a variable.
File:
// Query all variables
const variableNames = engine.variable.findAll();
// Set, get and remove a variable
engine.variable.setString('name', 'Chris');
const name = engine.variable.getString('name'); // Chris
engine.variable.remove('name');