Script Overview
Overview
Animation scripts are a first-class part of animationData and run through one shared command path.
- Script data is stored in
animationData.scripts. - Script actions use strict schema validation before execution.
- State-machine runtime and external API paths reuse the same command dispatcher.
Supported Hooks
onRun- Triggered when
playStateMachine(machineId)starts and script bindings match that machine.
- Triggered when
onStateChange- Triggered after a state transition is selected and applied.
You can also call editor.animation.runScriptHook(scriptId, hook, context) directly.
Supported Actions
set-inputfire-triggerset-object-propertyseek-timelineplay-state-machineset-script-input
set-script-input updates script-local inputs. Other actions are dispatched through the shared animation command executor.
Script Inputs
Script input types:
booleannumber(finite numbers only)trigger(boolean pulse:true -> false)string
Defaults are validated against declared input type.
Use fireScriptTrigger(scriptId, inputId) to pulse trigger inputs deterministically.
Binding Rules
Scripts can bind to:
stateMachinetimelineobjectglobal
For state-machine hook auto-run (onRun, onStateChange), scripts execute when binding is global or matches the active state machine id.
bindScript(scriptId, binding) returns a stable binding id that can be removed with unbindScript(scriptId, bindingId).
Diagnostics
Use editor.animation.getScriptDiagnostics(scriptId) to inspect last hook execution results.
Each entry includes:
- action payload
okstatus- execution message
- execution timestamp
Related Pages
- Script live demo: /docs/animation/script-live-demo-app.html
- Script inputs: /help/animation/script-inputs
- Script listener actions: /help/animation/script-listener-actions
- Script testing: /help/animation/script-testing