class_editorscript.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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 :kbd:`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.
  15. \ **Note:** Extending scripts need to have ``tool`` mode enabled.
  16. \ **Example script:**\
  17. ::
  18. tool
  19. extends EditorScript
  20. func _run():
  21. print("Hello from the Godot Editor!")
  22. \ **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.
  23. \ **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.
  24. .. rst-class:: classref-reftable-group
  25. Methods
  26. -------
  27. .. table::
  28. :widths: auto
  29. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`_run<class_EditorScript_method__run>` **(** **)** |virtual| |
  31. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
  33. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  34. | :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>` **(** **)** |
  35. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  36. | :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_get_scene>` **(** **)** |
  37. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  38. .. rst-class:: classref-section-separator
  39. ----
  40. .. rst-class:: classref-descriptions-group
  41. Method Descriptions
  42. -------------------
  43. .. _class_EditorScript_method__run:
  44. .. rst-class:: classref-method
  45. void **_run** **(** **)** |virtual|
  46. This method is executed by the Editor when **File > Run** is used.
  47. .. rst-class:: classref-item-separator
  48. ----
  49. .. _class_EditorScript_method_add_root_node:
  50. .. rst-class:: classref-method
  51. void **add_root_node** **(** :ref:`Node<class_Node>` node **)**
  52. Adds ``node`` as a child of the root node in the editor context.
  53. \ **Warning:** The implementation of this method is currently disabled.
  54. .. rst-class:: classref-item-separator
  55. ----
  56. .. _class_EditorScript_method_get_editor_interface:
  57. .. rst-class:: classref-method
  58. :ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
  59. Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_EditorScript_method_get_scene:
  63. .. rst-class:: classref-method
  64. :ref:`Node<class_Node>` **get_scene** **(** **)**
  65. Returns the Editor's currently active scene.
  66. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  67. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  68. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  69. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`