跳转至

EditorScript

继承

Reference

简要描述

可用于将扩展功能添加到编辑器的基本脚本。

描述

在编辑器运行时,可以从脚本编辑器的**File > Run**中(或通过按Ctrl+Shift+X)执行扩展此类并实现其_run方法的脚本。这对于将自定义的编辑器内功能添加到IdeaVR很有用。对于更复杂的添加,请考虑改为使用EditorPlugin

**注意:**扩展脚本需要启用tool模式。

示例脚本:

tool
extends EditorScript

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

**注意:**该脚本在编辑器上下文中运行,这意味着输出在以编辑器(stdout)开始的控制台窗口中可见,而不是通常的IdeaVR**Output**停靠栏。

方法

返回值类型 方法名称
void _run() virtual
void add_root_node(node: Node)
EditorInterface get_editor_interface()
Node get_scene()

方法说明

  • _run _run() virtual

当使用**File > Run**时,此方法由编辑器执行


  • add_root_node add_root_node(node: Node)

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

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


  • get_editor_interface get_editor_interface()

返回EditorInterface单例实例。


  • get_scene get_scene()

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