EditorScript

Inherits: Reference < Object

类别: 核心

简要说明

可用于向编辑器添加扩展函数的基本脚本。

方法

无效

_run ( ) virtual

无效

add_root_node ( Node node )

EditorInterface

get_editor_interface ( )

Node

get_scene ( )

描述

扩展此类并实现其 _run 方法可以从脚本编辑器的 File > Run 菜单选项(或按 Ctrl+Shift+X )当编辑器运行时。这对于将自定义编辑器功能添加到godot非常有用。对于更复杂的添加,请考虑使用 EditorPlugin 而是。

注: 扩展脚本需要 tool mode 启用。

示例脚本:

tool
extends EditorScript

func _run():
    print("Hello from the Godot Editor!")

注: 该脚本在编辑器上下文中运行,这意味着输出在以编辑器(stdout)启动的控制台窗口中可见,而不是通常的godot 产量 码头。

方法说明

  • void _run ( ) virtual

此方法由编辑器在以下情况下执行: File > Run 使用。

  • void add_root_node ( Node node )

添加 node 作为编辑器上下文中根节点的子级。

警告: 此方法的实现当前被禁用。

返回 EditorInterface 单例实例。

  • Node get_scene ( )

返回编辑器当前活动的场景。