0.2.0-dev Download ZIP
63 lines ·2.7 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="EditorScript" inherits="RefCounted" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Base script that can be used to add extension functions to the editor. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Scripts extending this class and implementing its [method _run] method can be executed from the Script Editor's [b]File > Run[/b] menu option (or by pressing [kbd]Ctrl + Shift + X[/kbd]) 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. |
| 8 | If a script extending this class also has a global class name, it will be included in the editor's command palette. |
| 9 | [b]Note:[/b] Extending scripts need to have [code]tool[/code] mode enabled. |
| 10 | [b]Example:[/b] Running the following script prints "Hello from the Godot Editor!": |
| 11 | [codeblocks] |
| 12 | [gdscript] |
| 13 | @tool |
| 14 | extends EditorScript |
| 15 | |
| 16 | func _run(): |
| 17 | print("Hello from the Godot Editor!") |
| 18 | [/gdscript] |
| 19 | [csharp] |
| 20 | using Godot; |
| 21 | |
| 22 | [Tool] |
| 23 | public partial class HelloEditor : EditorScript |
| 24 | { |
| 25 | public override void _Run() |
| 26 | { |
| 27 | GD.Print("Hello from the Godot Editor!"); |
| 28 | } |
| 29 | } |
| 30 | [/csharp] |
| 31 | [/codeblocks] |
| 32 | [b]Note:[/b] 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. |
| 33 | </description> |
| 34 | <tutorials> |
| 35 | </tutorials> |
| 36 | <methods> |
| 37 | <method name="_run" qualifiers="virtual required"> |
| 38 | <return type="void" /> |
| 39 | <description> |
| 40 | This method is executed by the Editor when [b]File > Run[/b] is used. |
| 41 | </description> |
| 42 | </method> |
| 43 | <method name="add_root_node" deprecated="Use [method EditorInterface.add_root_node] instead."> |
| 44 | <return type="void" /> |
| 45 | <param index="0" name="node" type="Node" /> |
| 46 | <description> |
| 47 | Makes [param node] root of the currently opened scene. Only works if the scene is empty. If the [param node] is a scene instance, an inheriting scene will be created. |
| 48 | </description> |
| 49 | </method> |
| 50 | <method name="get_editor_interface" qualifiers="const" deprecated="[EditorInterface] is a global singleton and can be accessed directly by its name."> |
| 51 | <return type="EditorInterface" /> |
| 52 | <description> |
| 53 | Returns the [EditorInterface] singleton instance. |
| 54 | </description> |
| 55 | </method> |
| 56 | <method name="get_scene" qualifiers="const" deprecated="Use [method EditorInterface.get_edited_scene_root] instead."> |
| 57 | <return type="Node" /> |
| 58 | <description> |
| 59 | Returns the edited (current) scene's root [Node]. Equivalent of [method EditorInterface.get_edited_scene_root]. |
| 60 | </description> |
| 61 | </method> |
| 62 | </methods> |
| 63 | </class> |