class_editorscript.rst 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the EditorScript.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_EditorScript:
  5. EditorScript
  6. ============
  7. **Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Base script that can be used to add extension functions to the editor.
  12. Member Functions
  13. ----------------
  14. +------------------------------------------------+-------------------------------------------------------------------------------------------------+
  15. | void | :ref:`_run<class_EditorScript__run>` **(** **)** virtual |
  16. +------------------------------------------------+-------------------------------------------------------------------------------------------------+
  17. | void | :ref:`add_root_node<class_EditorScript_add_root_node>` **(** :ref:`Node<class_node>` node **)** |
  18. +------------------------------------------------+-------------------------------------------------------------------------------------------------+
  19. | :ref:`EditorInterface<class_editorinterface>` | :ref:`get_editor_interface<class_EditorScript_get_editor_interface>` **(** **)** |
  20. +------------------------------------------------+-------------------------------------------------------------------------------------------------+
  21. | :ref:`Node<class_node>` | :ref:`get_scene<class_EditorScript_get_scene>` **(** **)** |
  22. +------------------------------------------------+-------------------------------------------------------------------------------------------------+
  23. Description
  24. -----------
  25. Scripts extending this class and implementing its ``_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. Note that extending scripts need to have ``tool mode`` enabled.
  26. Example script:
  27. ::
  28. tool
  29. extends EditorScript
  30. func _run():
  31. print("Hello from the Godot Editor!")
  32. Note that 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.
  33. Member Function Description
  34. ---------------------------
  35. .. _class_EditorScript__run:
  36. - void **_run** **(** **)** virtual
  37. This method is executed by the Editor when ``File -> Run`` is used.
  38. .. _class_EditorScript_add_root_node:
  39. - void **add_root_node** **(** :ref:`Node<class_node>` node **)**
  40. Adds ``node`` as a child of the root node in the editor context.
  41. WARNING: The implementation of this method is currently disabled.
  42. .. _class_EditorScript_get_editor_interface:
  43. - :ref:`EditorInterface<class_editorinterface>` **get_editor_interface** **(** **)**
  44. Returns the :ref:`EditorInterface<class_editorinterface>` singleton instance.
  45. .. _class_EditorScript_get_scene:
  46. - :ref:`Node<class_node>` **get_scene** **(** **)**
  47. Returns the Editor's currently active scene.