Editor Script
Usage
- Write the script by referring to the writing style of the Template and Example.
- Import the script into the editor.
- Select the script you want to execute and click the
Execute
button in theInspector
.
- Register to the menu bar
- Place the script in the
Scripts/_Editor
folder. - Export a
menuPath
string in the script. The string value will be the name displayed in the menu bar. You can use/
to separate levels. - If you need to add an icon to a script registered in the menu bar, you first need to import an image into the editor to convert it to
.tex
format, then place it in theScripts/_Editor/Icons
folder, and name it the same as themenuPath
string value in the script.
- Place the script in the
TIP
Registered menu bar items require an editor restart to take effect.
Hooks
The editor provides a total of 2 hooks, see BST/_Typings/editorApi/exportFuncs.d.ts.
menuPath
ts
export const menuPath: string
Used to register the script to the menu bar.
execute
ts
export const execute: () => void
Executed when the execute button is clicked.
Modules
The editor provides the following 6 modules:
For details, see BST/_Typings/editorApi/modules.
To import modules, use the following syntax:
js
import {
// modules
editor,
console,
file,
scene,
dialogWindowManager,
math,
// basic data types
Float2,
Float3,
Float4,
Bool3,
ColorRGBA,
Trans,
Quaternion,
} from "editorApi"
WARNING
Editor scripts cannot import custom modules.
Template
See BST/Templates/editorTemplate.js.