class_editorscript.rst 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.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. Base script that can be used to add extension functions to the editor.
  10. Description
  11. -----------
  12. 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.
  13. **Note:** Extending scripts need to have ``tool`` mode enabled.
  14. **Example script:**
  15. ::
  16. tool
  17. extends EditorScript
  18. func _run():
  19. print("Hello from the Godot Editor!")
  20. **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.
  21. Methods
  22. -------
  23. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`_run<class_EditorScript_method__run>` **(** **)** |virtual| |
  25. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
  27. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  28. | :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>` **(** **)** |
  29. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  30. | :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_get_scene>` **(** **)** |
  31. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  32. Method Descriptions
  33. -------------------
  34. .. _class_EditorScript_method__run:
  35. - void **_run** **(** **)** |virtual|
  36. This method is executed by the Editor when **File > Run** is used.
  37. ----
  38. .. _class_EditorScript_method_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. ----
  43. .. _class_EditorScript_method_get_editor_interface:
  44. - :ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
  45. Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
  46. ----
  47. .. _class_EditorScript_method_get_scene:
  48. - :ref:`Node<class_Node>` **get_scene** **(** **)**
  49. Returns the Editor's currently active scene.
  50. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  51. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  52. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`