EditorScript
继承: RefCounted
< Object
Base script that can be used to add extension functions to the editor.
描述
Scripts extending this class and implementing its _run
method can be executed from the Script Editor's File > Run menu option (or by pressing Ctrl + Shift + X
) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider using EditorPlugin
s instead.
Note: Extending scripts need to have tool
mode enabled.
Example script:
@tool
extends EditorScript
func _run():
print("Hello from the Godot Editor!")
using Godot;
[Tool]
public partial class HelloEditor : EditorScript
{
public override void _Run()
{
GD.Print("Hello from the Godot Editor!");
}
}
Note: The script is run in the Editor context, which means the output is visible in the console window started with the Editor (stdout) instead of the usual Godot Output dock.
Note: EditorScript is RefCounted
, meaning it is destroyed when nothing references it. This can cause errors during asynchronous operations if there are no references to the script.
方法
void | _run ( ) virtual1 |
void | add_root_node ( node: Node ) |
EditorInterface | get_editor_interface ( ) const2 |
Node | get_scene ( ) const2 |
方法说明
void
_run ( ) virtual1
This method is executed by the Editor when File > Run is used.
void
add_root_node ( node: Node
)
Makes node
root of the currently opened scene. Only works if the scene is empty. If the node
is a scene instance, an inheriting scene will be created.
EditorInterface
get_editor_interface ( ) const2
已弃用: EditorInterface
is a global singleton and can be accessed directly by its name.
Returns the EditorInterface
singleton instance.
Returns the edited (current) scene's root Node
. Equivalent of EditorInterface.get_edited_scene_root
.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。