Table of Contents

Class EditorScript

Namespace
Godot
Assembly
GodotSharpEditor.dll

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 EditorPlugins instead.

Note: Extending scripts need to have tool mode enabled.

Example script:

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.

public class EditorScript : RefCounted, IDisposable
Inheritance
EditorScript
Implements
Inherited Members

Constructors

EditorScript()

public EditorScript()

Methods

AddRootNode(Node)

Adds node as a child of the root node in the editor context.

Warning: The implementation of this method is currently disabled.

public void AddRootNode(Node node)

Parameters

node Node

GetEditorInterface()

Returns the EditorInterface singleton instance.

Deprecated. EditorInterface is a global singleton and can be accessed directly by its name.

[Obsolete("This method is deprecated.")]
public EditorInterface GetEditorInterface()

Returns

EditorInterface

GetScene()

Returns the Editor's currently active scene.

public Node GetScene()

Returns

Node

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

_Run()

This method is executed by the Editor when File > Run is used.

public virtual void _Run()