Skip to main content

Script

The Script Component enables an entity to run user-supplied scripts. In this way, the user can write scripts (using JavaScript or TypeScript) that run when the entity is instantiated and updated on a per-frame basis.

Script Component

Adding Scripts

To create a new script, click on the Add Script dropdown in the Script Component and either:

  • Select an existing script from the list
  • Type a new script name and click Create Script to create a new script asset

Alternatively, you can drag a script asset from the Assets Panel onto the Script Component.

Add Script Dialog

Script Panel Controls

Each script added to the component displays as a collapsible panel with the following controls:

ControlDescription
Script NameClick to select the script asset in the Assets Panel.
On/OffToggle to enable or disable this individual script.
EditOpens the script in the Code Editor.
ParseRe-parses the script to update its attributes. Use after modifying script attribute definitions.
RemoveRemoves the script from the component (click the X button).

Script Ordering

When multiple scripts are attached to an entity, their order matters. Scripts are executed from top to bottom. You can reorder scripts by dragging and dropping them within the component.

Script Attributes

Scripts can define custom attributes that appear in the Inspector. These attributes allow you to configure script behavior without modifying the code. Supported attribute types include:

  • boolean - Checkbox
  • number - Numeric input (with optional slider for min/max range)
  • string - Text input
  • vec2, vec3, vec4 - Vector inputs
  • rgb, rgba - Color picker
  • asset - Asset picker
  • entity - Entity picker
  • curve - Curve editor
  • json - Complex nested objects

See the Script Attributes documentation for details on defining attributes in your scripts.

See Also

Scripting Interface

The Script Component's scripting interface is here.