编辑器脚本
使用方法
- 注册至菜单栏
- 将脚本放入
Scripts/_Editor
文件夹中 - 在脚本中导出
menuPath
字符串,字符串值即为菜单栏中显示的名称,可用/
分隔层级 - 如果需要给注册到菜单栏中的脚本加上图标,则需要先将图片导入编辑器转为
.tex
格式,再将其放入Scripts/_Editor/Icons
文件夹中,并将其命名为脚本中menuPath
字符串值
- 将脚本放入
提示
注册的菜单栏项目需重启编辑器生效。
钩子
编辑器共提供了 2 个钩子,参见 BST/_Typings/editorApi/exportFuncs.d.ts。
menuPath
ts
export const menuPath: string
用于将脚本注册至菜单栏。
execute
ts
export const execute: () => void
点击执行按钮时执行。
模块
编辑器共提供了以下 6 个模块:
具体参见 BST/_Typings/editorApi/modules。
使用如下语法导入模块:
js
import {
// modules
editor,
console,
file,
scene,
dialogWindowManager,
math,
// basic data types
Float2,
Float3,
Float4,
Bool3,
ColorRGBA,
Trans,
Quaternion,
} from "editorApi"
注意
编辑器脚本 无法 导入自制模块。
模板
参见 BST/Templates/editorTemplate.js。