class_editorscript.rst 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/EditorScript.xml.
  6. .. _class_EditorScript:
  7. EditorScript
  8. ============
  9. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Base script that can be used to add extension functions to the editor.
  11. Description
  12. -----------
  13. Scripts extending this class and implementing its :ref:`_run<class_EditorScript_method__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 :ref:`EditorPlugin<class_EditorPlugin>`\ s instead.
  14. \ **Note:** Extending scripts need to have ``tool`` mode enabled.
  15. \ **Example script:**\
  16. ::
  17. tool
  18. extends EditorScript
  19. func _run():
  20. print("Hello from the Godot Editor!")
  21. \ **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.
  22. \ **Note:** EditorScript is reference counted, meaning it is destroyed when nothing references it. This can cause errors during asynchronous operations if there are no references to the script.
  23. Methods
  24. -------
  25. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`_run<class_EditorScript_method__run>` **(** **)** |virtual| |
  27. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
  29. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  30. | :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>` **(** **)** |
  31. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  32. | :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_get_scene>` **(** **)** |
  33. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  34. Method Descriptions
  35. -------------------
  36. .. _class_EditorScript_method__run:
  37. - void **_run** **(** **)** |virtual|
  38. This method is executed by the Editor when **File > Run** is used.
  39. ----
  40. .. _class_EditorScript_method_add_root_node:
  41. - void **add_root_node** **(** :ref:`Node<class_Node>` node **)**
  42. Adds ``node`` as a child of the root node in the editor context.
  43. \ **Warning:** The implementation of this method is currently disabled.
  44. ----
  45. .. _class_EditorScript_method_get_editor_interface:
  46. - :ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
  47. Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
  48. ----
  49. .. _class_EditorScript_method_get_scene:
  50. - :ref:`Node<class_Node>` **get_scene** **(** **)**
  51. Returns the Editor's currently active scene.
  52. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  53. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  54. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`