class_editorscript.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorScript.xml.
  6. .. _class_EditorScript:
  7. EditorScript
  8. ============
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :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. .. tabs::
  17. .. code-tab:: gdscript
  18. tool
  19. extends EditorScript
  20. func _run():
  21. print("Hello from the Godot Editor!")
  22. .. code-tab:: csharp
  23. using Godot;
  24. using System;
  25. [Tool]
  26. public class HelloEditor : EditorScript
  27. {
  28. public override void _Run()
  29. {
  30. GD.Print("Hello from the Godot Editor!");
  31. }
  32. }
  33. \ **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.
  34. Methods
  35. -------
  36. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`_run<class_EditorScript_method__run>` **(** **)** |virtual| |
  38. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`add_root_node<class_EditorScript_method_add_root_node>` **(** :ref:`Node<class_Node>` node **)** |
  40. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  41. | :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>` **(** **)** |
  42. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  43. | :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_get_scene>` **(** **)** |
  44. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------+
  45. Method Descriptions
  46. -------------------
  47. .. _class_EditorScript_method__run:
  48. - void **_run** **(** **)** |virtual|
  49. This method is executed by the Editor when **File > Run** is used.
  50. ----
  51. .. _class_EditorScript_method_add_root_node:
  52. - void **add_root_node** **(** :ref:`Node<class_Node>` node **)**
  53. Adds ``node`` as a child of the root node in the editor context.
  54. \ **Warning:** The implementation of this method is currently disabled.
  55. ----
  56. .. _class_EditorScript_method_get_editor_interface:
  57. - :ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
  58. Returns the :ref:`EditorInterface<class_EditorInterface>` singleton instance.
  59. ----
  60. .. _class_EditorScript_method_get_scene:
  61. - :ref:`Node<class_Node>` **get_scene** **(** **)**
  62. Returns the Editor's currently active scene.
  63. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  64. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  65. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  66. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  67. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  68. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`