EditorPlugin

Inherits: Node < Object

Utilizado por el editor para ampliar su funcionalidad.

Descripción

Los plugins son usados por el editor para extender la funcionalidad. Los tipos más comunes de plugins son los que editan un determinado nodo o tipo de recurso, importan plugins y exportan plugins. Véase también EditorScript para añadir funciones al editor.

Tutoriales

Métodos

void

add_autoload_singleton ( String name, String path )

ToolButton

add_control_to_bottom_panel ( Control control, String title )

void

add_control_to_container ( CustomControlContainer container, Control control )

void

add_control_to_dock ( DockSlot slot, Control control )

void

add_custom_type ( String type, String base, Script script, Texture icon )

void

add_export_plugin ( EditorExportPlugin plugin )

void

add_import_plugin ( EditorImportPlugin importer )

void

add_inspector_plugin ( EditorInspectorPlugin plugin )

void

add_scene_import_plugin ( EditorSceneImporter scene_importer )

void

add_spatial_gizmo_plugin ( EditorSpatialGizmoPlugin plugin )

void

add_tool_menu_item ( String name, Object handler, String callback, Variant ud=null )

void

add_tool_submenu_item ( String name, Object submenu )

void

apply_changes ( ) virtual

bool

build ( ) virtual

void

clear ( ) virtual

void

disable_plugin ( ) virtual

void

edit ( Object object ) virtual

void

enable_plugin ( ) virtual

void

forward_canvas_draw_over_viewport ( Control overlay ) virtual

void

forward_canvas_force_draw_over_viewport ( Control overlay ) virtual

bool

forward_canvas_gui_input ( InputEvent event ) virtual

void

forward_spatial_draw_over_viewport ( Control overlay ) virtual

void

forward_spatial_force_draw_over_viewport ( Control overlay ) virtual

bool

forward_spatial_gui_input ( Camera camera, InputEvent event ) virtual

PoolStringArray

get_breakpoints ( ) virtual

EditorInterface

get_editor_interface ( )

Texture

get_plugin_icon ( ) virtual

String

get_plugin_name ( ) virtual

ScriptCreateDialog

get_script_create_dialog ( )

Dictionary

get_state ( ) virtual

UndoRedo

get_undo_redo ( )

void

get_window_layout ( ConfigFile layout ) virtual

bool

handles ( Object object ) virtual

bool

has_main_screen ( ) virtual

void

hide_bottom_panel ( )

void

make_bottom_panel_item_visible ( Control item )

void

make_visible ( bool visible ) virtual

void

queue_save_layout ( ) const

void

remove_autoload_singleton ( String name )

void

remove_control_from_bottom_panel ( Control control )

void

remove_control_from_container ( CustomControlContainer container, Control control )

void

remove_control_from_docks ( Control control )

void

remove_custom_type ( String type )

void

remove_export_plugin ( EditorExportPlugin plugin )

void

remove_import_plugin ( EditorImportPlugin importer )

void

remove_inspector_plugin ( EditorInspectorPlugin plugin )

void

remove_scene_import_plugin ( EditorSceneImporter scene_importer )

void

remove_spatial_gizmo_plugin ( EditorSpatialGizmoPlugin plugin )

void

remove_tool_menu_item ( String name )

void

save_external_data ( ) virtual

void

set_force_draw_over_forwarding_enabled ( )

void

set_input_event_forwarding_always_enabled ( )

void

set_state ( Dictionary state ) virtual

void

set_window_layout ( ConfigFile layout ) virtual

int

update_overlays ( ) const

Señales

  • main_screen_changed ( String screen_name )

Emitido cuando el usuario cambia el espacio de trabajo (2D, 3D, Script, AssetLib). También funciona con pantallas personalizadas definidas por plugins.



  • scene_changed ( Node scene_root )

Emitido cuando se cambia la escena en el editor. El argumento devolverá el nodo raíz de la escena que se acaba de activar. Si esta escena es nueva y está vacía, el argumento será null.


  • scene_closed ( String filepath )

Emitido cuando el usuario cierra una escena. El argumento es la ruta de archivo a una escena cerrada.

Enumeraciones

enum CustomControlContainer:

  • CONTAINER_TOOLBAR = 0

  • CONTAINER_SPATIAL_EDITOR_MENU = 1

  • CONTAINER_SPATIAL_EDITOR_SIDE_LEFT = 2

  • CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT = 3

  • CONTAINER_SPATIAL_EDITOR_BOTTOM = 4

  • CONTAINER_CANVAS_EDITOR_MENU = 5

  • CONTAINER_CANVAS_EDITOR_SIDE_LEFT = 6

  • CONTAINER_CANVAS_EDITOR_SIDE_RIGHT = 7

  • CONTAINER_CANVAS_EDITOR_BOTTOM = 8

  • CONTAINER_PROPERTY_EDITOR_BOTTOM = 9

  • CONTAINER_PROJECT_SETTING_TAB_LEFT = 10

  • CONTAINER_PROJECT_SETTING_TAB_RIGHT = 11


enum DockSlot:

  • DOCK_SLOT_LEFT_UL = 0

  • DOCK_SLOT_LEFT_BL = 1

  • DOCK_SLOT_LEFT_UR = 2

  • DOCK_SLOT_LEFT_BR = 3

  • DOCK_SLOT_RIGHT_UL = 4

  • DOCK_SLOT_RIGHT_BL = 5

  • DOCK_SLOT_RIGHT_UR = 6

  • DOCK_SLOT_RIGHT_BR = 7

  • DOCK_SLOT_MAX = 8 --- Representa el tamaño del enum DockSlot.

Descripciones de Métodos

Añade un script en path a la lista de Autoload como name.


Añade un control al panel inferior (junto con la salida, depuración, animación, etc.). Devuelve una referencia al botón añadido. Depende de ti ocultar/mostrar el botón cuando sea necesario. Cuando tu plugin está desactivado, asegúrate de quitar tu control personalizado con remove_control_from_bottom_panel y libéralo con Node.queue_free.


Añade un control personalizado a un contenedor (véase CustomControlContainer). Hay muchas ubicaciones donde se pueden agregar controles personalizados en la interfaz de usuario del editor.

Por favor, recuerde que tiene que gestionar la visibilidad de sus controles personalizados usted mismo (y probablemente lo oculte después de añadirlo).

Cuando tu plugin esté desactivado, asegúrate de eliminar tu control personalizado con remove_control_from_container y libéralo con Node.queue_free.


Añade el control a una ranura específica del dock (ver DockSlot para las opciones).

Si se reposiciona el dock y mientras el plugin esté activo, el editor guardará la posición del dock en sesiones posteriores.

Cuando tu plugin esté desactivado, asegúrate de eliminar tu control personalizado con remove_control_from_docks y libéralo con Node.queue_free.


Adds a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed.

When given node or resource is selected, the base type will be instanced (ie, "Spatial", "Control", "Resource"), then the script will be loaded and set to this object.

You can use the virtual method handles to check if your custom object is being edited by checking the script or using the is keyword.

During run-time, this will be a simple object with a script so this function does not need to be called then.


Registers a new EditorExportPlugin. Export plugins are used to perform tasks when the project is being exported.

See add_inspector_plugin for an example of how to register a plugin.


Registers a new EditorImportPlugin. Import plugins are used to import custom and unsupported assets as a custom Resource type.

Note: If you want to import custom 3D asset formats use add_scene_import_plugin instead.

See add_inspector_plugin for an example of how to register a plugin.


Registers a new EditorInspectorPlugin. Inspector plugins are used to extend EditorInspector and provide custom configuration tools for your object's properties.

Note: Always use remove_inspector_plugin to remove the registered EditorInspectorPlugin when your EditorPlugin is disabled to prevent leaks and an unexpected behavior.

const MyInspectorPlugin = preload("res://addons/your_addon/path/to/your/script.gd")
var inspector_plugin = MyInspectorPlugin.new()

func _enter_tree():
    add_inspector_plugin(inspector_plugin)

func _exit_tree():
    remove_inspector_plugin(inspector_plugin)

Registers a new EditorSceneImporter. Scene importers are used to import custom 3D asset formats as scenes.


Registers a new EditorSpatialGizmoPlugin. Gizmo plugins are used to add custom gizmos to the 3D preview viewport for a Spatial.

See add_inspector_plugin for an example of how to register a plugin.


Añade un elemento de menú personalizado a Proyecto > Herramientas como name que llama a callback en una instancia de handler con un parámetro ud cuando el usuario lo activa.


  • void add_tool_submenu_item ( String name, Object submenu )

Añade un submenú personalizado en Proyecto > Herramientas > name. El submenu debe ser un objeto de la clase PopupMenu. Este submenú debe ser limpiado usando remove_tool_menu_item(name).


  • void apply_changes ( ) virtual

Este método se llama cuando el editor está a punto de guardar el proyecto, cambiar a otra pestaña, etc. Le pide al plugin que aplique cualquier cambio de estado pendiente para asegurar la consistencia.

Se utiliza, por ejemplo, en los editores de sombreadores para que el plugin sepa que debe aplicar el código de sombreado que está escribiendo el usuario al objeto.


  • bool build ( ) virtual

This method is called when the editor is about to run the project. The plugin can then perform required operations before the project runs.

This method must return a boolean. If this method returns false, the project will not run. The run is aborted immediately, so this also prevents all other plugins' build methods from running.


  • void clear ( ) virtual

Borra todo el estado y pone a cero el objeto que se está editando. Esto asegura que tu plugin no siga editando un nodo existente o un nodo de la escena equivocada.


  • void disable_plugin ( ) virtual

Llamado por el motor cuando el usuario desactiva el EditorPlugin en la pestaña Plugin de la ventana de configuración del proyecto.


  • void edit ( Object object ) virtual

Esta función se utiliza para los plugins que editan tipos de objetos específicos (nodos o recursos). Solicita al editor que edite el objeto dado.


  • void enable_plugin ( ) virtual

Llamado por el motor cuando el usuario habilita el EditorPlugin en la pestaña Plugin de la ventana de configuración del proyecto.


  • void forward_canvas_draw_over_viewport ( Control overlay ) virtual

Called by the engine when the 2D editor's viewport is updated. Use the overlay Control for drawing. You can update the viewport manually by calling update_overlays.

func forward_canvas_draw_over_viewport(overlay):
    # Draw a circle at cursor position.
    overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.white)

func forward_canvas_gui_input(event):
    if event is InputEventMouseMotion:
        # Redraw viewport when cursor is moved.
        update_overlays()
        return true
    return false

  • void forward_canvas_force_draw_over_viewport ( Control overlay ) virtual

This method is the same as forward_canvas_draw_over_viewport, except it draws on top of everything. Useful when you need an extra layer that shows over anything else.

You need to enable calling of this method by using set_force_draw_over_forwarding_enabled.


Llamado cuando hay un nodo raíz en la escena editada actual, se implementa handles y se produce un InputEvent en la vista 2D. Intercepta el InputEvent, si return true EditorPlugin consume el event, de lo contrario reenvía el event a otras clases de Editor. Ejemplo:

# Previene que el InputEvent se reenvie a otras clases Editor
func forward_canvas_gui_input(event):
    var adelante = true
    return adelante

Obliga return false para reenviar a otras clases Editor el InputEvent. Ejemplo:

# Consume InputEventMouseMotion  y lo reenvia hacia otros tipos InputEvent
func forward_canvas_gui_input(event):
    var adelante = false
    if event is InputEventMouseMotion:
        adelante = true
    return adelante

  • void forward_spatial_draw_over_viewport ( Control overlay ) virtual

Called by the engine when the 3D editor's viewport is updated. Use the overlay Control for drawing. You can update the viewport manually by calling update_overlays.

func forward_spatial_draw_over_viewport(overlay):
    # Draw a circle at cursor position.
    overlay.draw_circle(overlay.get_local_mouse_position(), 64)

func forward_spatial_gui_input(camera, event):
    if event is InputEventMouseMotion:
        # Redraw viewport when cursor is moved.
        update_overlays()
        return true
    return false

  • void forward_spatial_force_draw_over_viewport ( Control overlay ) virtual

This method is the same as forward_spatial_draw_over_viewport, except it draws on top of everything. Useful when you need an extra layer that shows over anything else.

You need to enable calling of this method by using set_force_draw_over_forwarding_enabled.


Llamado cuando hay un nodo raíz en la escena editada actual, se implementa handles y se produce un InputEvent en el puerto de visualización 3D. Intercepta el InputEvent, si devuelve true EditorPlugin consume el event, de lo contrario reenvía el event a otras clases de Editor. Ejemplo:

#  Evita que el InputEvent llegue a otras clases de editores
func forward_spatial_gui_input(camera, event):
    var adelante = true
    return adelante

Debe return false para reenviar el InputEvent a otras clases de editores. Ejemplo:

# Consume el InputEventMouseMotion y reenvía otros tipos de InputEvent
func forward_spatial_gui_input(camera, event):
    var adelante = false
    if event is InputEventMouseMotion:
        adelante = true
    return adelante

Esto es para los editores que editan objetos basados en scripts. Puede devolver una lista de puntos de interrupción en el formato (script:line), por ejemplo: res://ruta_a_script.gd:25.


Devuelve el objeto EditorInterface que le da el control sobre la ventana del editor de Godot y sus funcionalidades.


  • Texture get_plugin_icon ( ) virtual

Override this method in your plugin to return a Texture in order to give it an icon.

For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons.

Ideally, the plugin icon should be white with a transparent background and 16x16 pixels in size.

func get_plugin_icon():
    # You can use a custom icon:
    return preload("res://addons/my_plugin/my_plugin_icon.svg")
    # Or use a built-in icon:
    return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons")

  • String get_plugin_name ( ) virtual

Sobrescribe este método en tu plugin para proporcionar el nombre del plugin cuando se muestra en el editor de Godot.

Para los plugins de la pantalla principal, esto aparece en la parte superior de la pantalla, a la derecha de los botones "2D", "3D", "Script" y "AssetLib".


Gets the Editor's dialogue used for making scripts.

Note: Users can configure it before use.

Warning: Removing and freeing this node will render a part of the editor useless and may cause a crash.


Obtiene el estado de su editor de plugins. Se usa cuando se guarda la escena (así que el estado se mantiene al abrirla de nuevo) y para cambiar de pestaña (así que el estado puede ser restaurado cuando la pestaña vuelve).


Consigue el objeto deshacer/rehacer. La mayoría de las acciones del editor pueden deshacerse, así que usa este objeto para asegurarte de que esto ocurra cuando valga la pena.


  • void get_window_layout ( ConfigFile layout ) virtual

Consigue el diseño de la interfaz gráfica del plugin. Se utiliza para guardar la disposición del editor del proyecto cuando se llama a queue_save_layout o se ha cambiado la disposición del editor (por ejemplo, cambiando la posición de un dock).


Implementa esta función si tu plugin edita un tipo específico de objeto (Recurso o Nodo). Si devuelves true, entonces obtendrás las funciones edit y make_visible llamadas cuando el editor las solicite. Si has declarado los métodos forward_canvas_gui_input y forward_spatial_gui_input estos serán llamados también.


  • bool has_main_screen ( ) virtual

Devuelve true si se trata de un plugin de editor de pantalla principal (va en el selector de espacio de trabajo junto con 2D, 3D, Script y AssetLib).


  • void hide_bottom_panel ( )

Minimizes the bottom panel.


  • void make_bottom_panel_item_visible ( Control item )

Makes a specific item in the bottom panel visible.


  • void make_visible ( bool visible ) virtual

Esta función será llamada cuando se solicite que el editor se haga visible. Se utiliza para los plugins que editan un tipo de objeto específico.

Recuerda que tienes que gestionar la visibilidad de todos los controles del editor de forma manual.


  • void queue_save_layout ( ) const

La cola guarda el diseño del editor del proyecto.


  • void remove_autoload_singleton ( String name )

Elimina un Autoload name de la lista.


  • void remove_control_from_bottom_panel ( Control control )

Quita el control del panel inferior. Tienes que manualmente Node.queue_free el control.


Retira el control del contenedor especificado. Tienes que hacer manualmente Node.queue_free el control.


  • void remove_control_from_docks ( Control control )

Quita el control del dock. Tienes que manualmente Node.queue_free el control.


  • void remove_custom_type ( String type )

Elimina un tipo personalizado añadido por add_custom_type.


Removes an export plugin registered by add_export_plugin.


Removes an import plugin registered by add_import_plugin.


Removes an inspector plugin registered by add_import_plugin


Removes a scene importer registered by add_scene_import_plugin.


Removes a gizmo plugin registered by add_spatial_gizmo_plugin.


  • void remove_tool_menu_item ( String name )

Elimina un menú name de Proyecto > Herramientas.


  • void save_external_data ( ) virtual

Este método se llama después de que el editor guarda el proyecto o cuando se cierra. Le pide al plugin que guarde las escenas/recursos externos editados.


  • void set_force_draw_over_forwarding_enabled ( )

Enables calling of forward_canvas_force_draw_over_viewport for the 2D editor and forward_spatial_force_draw_over_viewport for the 3D editor when their viewports are updated. You need to call this method only once and it will work permanently for this plugin.


  • void set_input_event_forwarding_always_enabled ( )

Utilice este método si siempre quiere recibir entradas de la pantalla de vista 3D dentro de forward_spatial_gui_input. Puede ser especialmente útil si tu plugin quiere usar raycast en la escena.


Restaurar el estado guardado por get_state.


  • void set_window_layout ( ConfigFile layout ) virtual

Restaurar el diseño del plugin GUI guardado por get_window_layout.


  • int update_overlays ( ) const

Updates the overlays of the 2D and 3D editor viewport. Causes methods forward_canvas_draw_over_viewport, forward_canvas_force_draw_over_viewport, forward_spatial_draw_over_viewport and forward_spatial_force_draw_over_viewport to be called.