class_editorscript.rst 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 :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.
  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. Methods
  23. -------
  24. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`_run<class_EditorScript_method__run>` **(** **)** |virtual| |
  26. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
  28. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  29. | :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>` **(** **)** |
  30. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  31. | :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_get_scene>` **(** **)** |
  32. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  33. Method Descriptions
  34. -------------------
  35. .. _class_EditorScript_method__run:
  36. - void **_run** **(** **)** |virtual|
  37. This method is executed by the Editor when **File > Run** is used.
  38. ----
  39. .. _class_EditorScript_method_add_root_node:
  40. - void **add_root_node** **(** :ref:`Node<class_Node>` node **)**
  41. Adds ``node`` as a child of the root node in the editor context.
  42. \ **Warning:** The implementation of this method is currently disabled.
  43. ----
  44. .. _class_EditorScript_method_get_editor_interface:
  45. - :ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
  46. Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
  47. ----
  48. .. _class_EditorScript_method_get_scene:
  49. - :ref:`Node<class_Node>` **get_scene** **(** **)**
  50. Returns the Editor's currently active scene.
  51. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  52. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  53. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`