Manage Variables
In this example, we will show you how to use the CreativeEditor SDK's Creative Engine to modify variables through the variable
API. The variable
API lets you set or get the contents of variables that exist in your scene.
To learn more about variables, have a look at their documentation.
Explore a full code sample of the integration on CodeSandbox or view the code on GitHub.
Setup#
This example uses the headless Creative Engine. See the Setup article for a detailed guide.
To get started right away, you can also access the variable
API within a running CE.SDK instance via cesdk.engine.variable
.
Check out the APIs Overview to see that illustrated in more detail.
Variables#
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:
import 'https://cdn.img.ly/packages/imgly/cesdk-js/1.7.0/cesdk-engine.umd.js';const config = {baseURL: 'https://cdn.img.ly/packages/imgly/cesdk-js/1.7.0/assets'};CreativeEngine.init(config).then(async (engine) => {const variableNames = engine.variable.findAll();engine.variable.setString('name', 'Chris');const name = engine.variable.getString('name');engine.variable.remove('name');engine.dispose();});
Previous
Observe Events
Next
Manage Assets