:github_url: hide .. _class_EditorScript: EditorScript ============ **Hereda:** :ref:`RefCounted` **<** :ref:`Object` Script base que puede ser usado para añadir funciones de extensión al editor. .. rst-class:: classref-introduction-group Descripción ---------------------- Scripts extending this class and implementing its :ref:`_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`\ s instead. If a script extending this class also has a global class name, it will be included in the editor's command palette. \ **Note:** Extending scripts need to have ``tool`` mode enabled. \ **Example:** Running the following script prints "Hello from the Godot Editor!": .. tabs:: .. code-tab:: gdscript @tool extends EditorScript func _run(): print("Hello from the Godot Editor!") .. code-tab:: csharp using Godot; [Tool] public partial class HelloEditor : EditorScript { public override void _Run() { GD.Print("Hello from the Godot Editor!"); } } \ **Note:** EditorScript is :ref:`RefCounted`, meaning it is destroyed when nothing references it. This can cause errors during asynchronous operations if there are no references to the script. .. rst-class:: classref-reftable-group Métodos -------------- .. table:: :widths: auto +-----------------------------------------------+-----------------------------------------------------------------------------------------------------+ | |void| | :ref:`_run`\ (\ ) |virtual| |required| | +-----------------------------------------------+-----------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_root_node`\ (\ node\: :ref:`Node`\ ) | +-----------------------------------------------+-----------------------------------------------------------------------------------------------------+ | :ref:`EditorInterface` | :ref:`get_editor_interface`\ (\ ) |const| | +-----------------------------------------------+-----------------------------------------------------------------------------------------------------+ | :ref:`Node` | :ref:`get_scene`\ (\ ) |const| | +-----------------------------------------------+-----------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descripciones de Métodos ------------------------------------------------ .. _class_EditorScript_private_method__run: .. rst-class:: classref-method |void| **_run**\ (\ ) |virtual| |required| :ref:`🔗` Este método es ejecutado por el Editor cuando se utiliza **Archivo > Ejecutar**. .. rst-class:: classref-item-separator ---- .. _class_EditorScript_method_add_root_node: .. rst-class:: classref-method |void| **add_root_node**\ (\ node\: :ref:`Node`\ ) :ref:`🔗` **Obsoleto:** Use :ref:`EditorInterface.add_root_node()` instead. Convierte a ``node`` en la raíz de la escena actualmente abierta. Solo funciona si la escena está vacía. Si ``node`` es una instancia de escena, se creará una escena heredada. .. rst-class:: classref-item-separator ---- .. _class_EditorScript_method_get_editor_interface: .. rst-class:: classref-method :ref:`EditorInterface` **get_editor_interface**\ (\ ) |const| :ref:`🔗` **Obsoleto:** :ref:`EditorInterface` is a global singleton and can be accessed directly by its name. Devuelve la instancia singleton :ref:`EditorInterface`. .. rst-class:: classref-item-separator ---- .. _class_EditorScript_method_get_scene: .. rst-class:: classref-method :ref:`Node` **get_scene**\ (\ ) |const| :ref:`🔗` **Obsoleto:** Use :ref:`EditorInterface.get_edited_scene_root()` instead. Devuelve la raíz :ref:`Node` de la escena editada (actual). Equivalente de :ref:`EditorInterface.get_edited_scene_root()`. .. |virtual| replace:: :abbr:`virtual (Normalmente, este método debería ser sobreescrito por el usuario para que tenga algún efecto.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (Este método no tiene efectos secundarios. No modifica ninguna de las variables miembro de la instancia.)` .. |vararg| replace:: :abbr:`vararg (Este método permite agregar cualquier número de argumentos después de los descritos aquí.)` .. |constructor| replace:: :abbr:`constructor (Este método se utiliza para construir un tipo.)` .. |static| replace:: :abbr:`static (Este método no necesita una instancia para ser llamado, por lo que puede llamarse directamente utilizando el nombre de la clase.)` .. |operator| replace:: :abbr:`operator (Este método describe un operador válido para usar con este tipo como operando izquierdo.)` .. |bitfield| replace:: :abbr:`BitField (Este valor es un entero compuesto como una máscara de bits de las siguientes banderas.)` .. |void| replace:: :abbr:`void (Sin valor de retorno.)`