EditorScript
可以用于开发简单的编辑器脚本
- 它继承于
Reference<Object
,因此它不是挂到场景节点来执行的,可以直接通过脚本编辑器来执行它 - 需要在
tool
模式下运行
范例代码
tool
#MyEditorScript.gd
extends EditorScript
func _run():
print("hello")
也可以使用快捷键Control + Shift + x
执行
常用方法 | 说明 |
---|---|
void _run() virtual |
Control + Shift + x 时执行 |
void add_root_node(node: Node) |
在 root 下添加一个节点,目前版本被禁用 |
EditorInterface get_editor_interface() |
返回EditorInterface 单例对象 |
EditorInterface get_editor_interface() |
返回当前激活的场景 |
小结
EditorScript
适用于简单的编辑器脚本开发,如果开发复杂的编辑器脚本,需要使用EditorPlugin