EditorScript.xml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="EditorScript" inherits="RefCounted" 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 &gt; 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. [b]Note:[/b] Extending scripts need to have [code]tool[/code] mode enabled.
  9. [b]Example script:[/b]
  10. [codeblocks]
  11. [gdscript]
  12. @tool
  13. extends EditorScript
  14. func _run():
  15. print("Hello from the Godot Editor!")
  16. [/gdscript]
  17. [csharp]
  18. using Godot;
  19. [Tool]
  20. public partial class HelloEditor : EditorScript
  21. {
  22. public override void _Run()
  23. {
  24. GD.Print("Hello from the Godot Editor!");
  25. }
  26. }
  27. [/csharp]
  28. [/codeblocks]
  29. [b]Note:[/b] 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 [b]Output[/b] dock.
  30. [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.
  31. </description>
  32. <tutorials>
  33. </tutorials>
  34. <methods>
  35. <method name="_run" qualifiers="virtual">
  36. <return type="void" />
  37. <description>
  38. This method is executed by the Editor when [b]File &gt; Run[/b] is used.
  39. </description>
  40. </method>
  41. <method name="add_root_node">
  42. <return type="void" />
  43. <param index="0" name="node" type="Node" />
  44. <description>
  45. 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.
  46. </description>
  47. </method>
  48. <method name="get_editor_interface" qualifiers="const" deprecated="[EditorInterface] is a global singleton and can be accessed directly by its name.">
  49. <return type="EditorInterface" />
  50. <description>
  51. Returns the [EditorInterface] singleton instance.
  52. </description>
  53. </method>
  54. <method name="get_scene" qualifiers="const">
  55. <return type="Node" />
  56. <description>
  57. Returns the edited (current) scene's root [Node]. Equivalent of [method EditorInterface.get_edited_scene_root].
  58. </description>
  59. </method>
  60. </methods>
  61. </class>