EditorScript
Inherits:RefCounted<Object
Base script that can be used to add extension functions to the editor.
Description
Scripts extending this class and implementing its_run() method can be executed from the Script Editor'sFile > Run menu option (or by pressingCtrl+Shift+X) while the editor is running. This is useful for adding custom in-editor functionality to Godot. For more complex additions, consider usingEditorPlugins instead.
Note: Extending scripts need to havetool
mode enabled.
Example: Running the following script prints "Hello from the Godot Editor!":
@toolextendsEditorScriptfunc_run():print("Hello from the Godot Editor!")
usingGodot;[Tool]publicpartialclassHelloEditor:EditorScript{publicoverridevoid_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 GodotOutput dock.
Note: EditorScript isRefCounted, meaning it is destroyed when nothing references it. This can cause errors during asynchronous operations if there are no references to the script.
Methods
add_root_node(node:Node) | |
Method Descriptions
This method is executed by the Editor whenFile > Run is used.
Makesnode
root of the currently opened scene. Only works if the scene is empty. If thenode
is a scene instance, an inheriting scene will be created.
EditorInterfaceget_editor_interface()const🔗
Deprecated:EditorInterface is a global singleton and can be accessed directly by its name.
Returns theEditorInterface singleton instance.
Returns the edited (current) scene's rootNode. Equivalent ofEditorInterface.get_edited_scene_root().