:github_url: hide .. _class_EditorDebuggerPlugin: EditorDebuggerPlugin ==================== **Hereda:** :ref:`RefCounted` **<** :ref:`Object` Una clase base para implementar plugins de depuración. .. rst-class:: classref-introduction-group Descripción ---------------------- **EditorDebuggerPlugin** provides functions related to the editor side of the debugger. To interact with the debugger, an instance of this class must be added to the editor via :ref:`EditorPlugin.add_debugger_plugin()`. Once added, the :ref:`_setup_session()` callback will be called for every :ref:`EditorDebuggerSession` available to the plugin, and when new ones are created (the sessions may be inactive during this stage). You can retrieve the available :ref:`EditorDebuggerSession`\ s via :ref:`get_sessions()` or get a specific one via :ref:`get_session()`. .. tabs:: .. code-tab:: gdscript @tool extends EditorPlugin class ExampleEditorDebugger extends EditorDebuggerPlugin: func _has_capture(capture): # Return true if you wish to handle messages with the prefix "my_plugin:". return capture == "my_plugin" func _capture(message, data, session_id): if message == "my_plugin:ping": get_session(session_id).send_message("my_plugin:echo", data) return true return false func _setup_session(session_id): # Add a new tab in the debugger session UI containing a label. var label = Label.new() label.name = "Example plugin" # Will be used as the tab title. label.text = "Example plugin" var session = get_session(session_id) # Listens to the session started and stopped signals. session.started.connect(func (): print("Session started")) session.stopped.connect(func (): print("Session stopped")) session.add_session_tab(label) var debugger = ExampleEditorDebugger.new() func _enter_tree(): add_debugger_plugin(debugger) func _exit_tree(): remove_debugger_plugin(debugger) To connect on the running game side, use the :ref:`EngineDebugger` singleton: .. tabs:: .. code-tab:: gdscript extends Node func _ready(): EngineDebugger.register_message_capture("my_plugin", _capture) EngineDebugger.send_message("my_plugin:ping", ["test"]) func _capture(message, data): # Note that the "my_plugin:" prefix is not used here. if message == "echo": prints("Echo received:", data) return true return false \ **Note:** While the game is running, :ref:`@GlobalScope.print()` and similar functions *called in the editor* do not print anything, the Output Log prints only game messages. .. rst-class:: classref-reftable-group Métodos -------------- .. table:: :widths: auto +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_breakpoint_set_in_tree`\ (\ script\: :ref:`Script`, line\: :ref:`int`, enabled\: :ref:`bool`\ ) |virtual| | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_breakpoints_cleared_in_tree`\ (\ ) |virtual| | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_capture`\ (\ message\: :ref:`String`, data\: :ref:`Array`, session_id\: :ref:`int`\ ) |virtual| | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_goto_script_line`\ (\ script\: :ref:`Script`, line\: :ref:`int`\ ) |virtual| | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`_has_capture`\ (\ capture\: :ref:`String`\ ) |virtual| |const| | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_setup_session`\ (\ session_id\: :ref:`int`\ ) |virtual| | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`EditorDebuggerSession` | :ref:`get_session`\ (\ id\: :ref:`int`\ ) | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_sessions`\ (\ ) | +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descripciones de Métodos ------------------------------------------------ .. _class_EditorDebuggerPlugin_private_method__breakpoint_set_in_tree: .. rst-class:: classref-method |void| **_breakpoint_set_in_tree**\ (\ script\: :ref:`Script`, line\: :ref:`int`, enabled\: :ref:`bool`\ ) |virtual| :ref:`🔗` Sobrescribe este método para recibir una notificación cuando se establezca un punto de interrupción en el editor. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_private_method__breakpoints_cleared_in_tree: .. rst-class:: classref-method |void| **_breakpoints_cleared_in_tree**\ (\ ) |virtual| :ref:`🔗` Sobrescribe este método para recibir una notificación cuando se borren todos los puntos de interrupción en el editor. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_private_method__capture: .. rst-class:: classref-method :ref:`bool` **_capture**\ (\ message\: :ref:`String`, data\: :ref:`Array`, session_id\: :ref:`int`\ ) |virtual| :ref:`🔗` Override this method to process incoming messages. The ``session_id`` is the ID of the :ref:`EditorDebuggerSession` that received the ``message``. Use :ref:`get_session()` to retrieve the session. This method should return ``true`` if the message is recognized. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_private_method__goto_script_line: .. rst-class:: classref-method |void| **_goto_script_line**\ (\ script\: :ref:`Script`, line\: :ref:`int`\ ) |virtual| :ref:`🔗` Sobrescribe este método para recibir una notificación cuando se haga clic en una línea de punto de interrupción en el panel de puntos de interrupción del depurador. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_private_method__has_capture: .. rst-class:: classref-method :ref:`bool` **_has_capture**\ (\ capture\: :ref:`String`\ ) |virtual| |const| :ref:`🔗` Override this method to enable receiving messages from the debugger. If ``capture`` is "my_message" then messages starting with "my_message:" will be passed to the :ref:`_capture()` method. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_private_method__setup_session: .. rst-class:: classref-method |void| **_setup_session**\ (\ session_id\: :ref:`int`\ ) |virtual| :ref:`🔗` Sobrescribe este método para recibir una notificación cada vez que se cree una nueva :ref:`EditorDebuggerSession`. Ten en cuenta que la sesión puede estar inactiva durante esta etapa. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_method_get_session: .. rst-class:: classref-method :ref:`EditorDebuggerSession` **get_session**\ (\ id\: :ref:`int`\ ) :ref:`🔗` Devuelve la :ref:`EditorDebuggerSession` con el ``id`` indicado. .. rst-class:: classref-item-separator ---- .. _class_EditorDebuggerPlugin_method_get_sessions: .. rst-class:: classref-method :ref:`Array` **get_sessions**\ (\ ) :ref:`🔗` Returns an array of :ref:`EditorDebuggerSession` currently available to this debugger plugin. \ **Note:** Sessions in the array may be inactive, check their state via :ref:`EditorDebuggerSession.is_active()`. .. |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.)`