class_editorscript.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the EditorScript.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_EditorScript:
  6. EditorScript
  7. ============
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Base script that can be used to add extension functions to the editor.
  13. Methods
  14. -------
  15. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`_run<class_EditorScript_method__run>` **(** **)** virtual |
  17. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
  19. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  20. | :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>` **(** **)** |
  21. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  22. | :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_get_scene>` **(** **)** |
  23. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  24. Description
  25. -----------
  26. 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.
  27. **Note:** Extending scripts need to have ``tool`` mode enabled.
  28. **Example script:**
  29. ::
  30. tool
  31. extends EditorScript
  32. func _run():
  33. print("Hello from the Godot Editor!")
  34. **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.
  35. Method Descriptions
  36. -------------------
  37. .. _class_EditorScript_method__run:
  38. - void **_run** **(** **)** virtual
  39. This method is executed by the Editor when **File > Run** is used.
  40. ----
  41. .. _class_EditorScript_method_add_root_node:
  42. - void **add_root_node** **(** :ref:`Node<class_Node>` node **)**
  43. Adds ``node`` as a child of the root node in the editor context.
  44. **Warning:** The implementation of this method is currently disabled.
  45. ----
  46. .. _class_EditorScript_method_get_editor_interface:
  47. - :ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
  48. Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
  49. ----
  50. .. _class_EditorScript_method_get_scene:
  51. - :ref:`Node<class_Node>` **get_scene** **(** **)**
  52. Returns the Editor's currently active scene.