Files
godot-docs-l10n/classes/es/class_editorscript.rst
2025-09-30 13:31:55 +02:00

135 lines
5.8 KiB
ReStructuredText

:github_url: hide
.. _class_EditorScript:
EditorScript
============
**Hereda:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_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()<class_EditorScript_private_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.
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<class_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<class_EditorScript_private_method__run>`\ (\ ) |virtual| |required| |
+-----------------------------------------------+-----------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_root_node<class_EditorScript_method_add_root_node>`\ (\ node\: :ref:`Node<class_Node>`\ ) |
+-----------------------------------------------+-----------------------------------------------------------------------------------------------------+
| :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorScript_method_get_editor_interface>`\ (\ ) |const| |
+-----------------------------------------------+-----------------------------------------------------------------------------------------------------+
| :ref:`Node<class_Node>` | :ref:`get_scene<class_EditorScript_method_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:`🔗<class_EditorScript_private_method__run>`
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<class_Node>`\ ) :ref:`🔗<class_EditorScript_method_add_root_node>`
Makes ``node`` root of the currently opened scene. Only works if the scene is empty. If the ``node`` is a scene instance, an inheriting scene will be created.
.. rst-class:: classref-item-separator
----
.. _class_EditorScript_method_get_editor_interface:
.. rst-class:: classref-method
:ref:`EditorInterface<class_EditorInterface>` **get_editor_interface**\ (\ ) |const| :ref:`🔗<class_EditorScript_method_get_editor_interface>`
**Obsoleto:** :ref:`EditorInterface<class_EditorInterface>` is a global singleton and can be accessed directly by its name.
Devuelve la instancia singleton :ref:`EditorInterface<class_EditorInterface>`.
.. rst-class:: classref-item-separator
----
.. _class_EditorScript_method_get_scene:
.. rst-class:: classref-method
:ref:`Node<class_Node>` **get_scene**\ (\ ) |const| :ref:`🔗<class_EditorScript_method_get_scene>`
Devuelve la raíz :ref:`Node<class_Node>` de la escena editada (actual). Equivalente de :ref:`EditorInterface.get_edited_scene_root()<class_EditorInterface_method_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.)`