Files
godot-docs/classes/class_editordebuggerplugin.rst
2024-05-07 11:26:31 +00:00

163 lines
8.5 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/EditorDebuggerPlugin.xml.
.. _class_EditorDebuggerPlugin:
EditorDebuggerPlugin
====================
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
A base class to implement debugger plugins.
.. rst-class:: classref-introduction-group
Description
-----------
**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<class_EditorPlugin_method_add_debugger_plugin>`.
Once added, the :ref:`_setup_session<class_EditorDebuggerPlugin_private_method__setup_session>` callback will be called for every :ref:`EditorDebuggerSession<class_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<class_EditorDebuggerSession>`\ s via :ref:`get_sessions<class_EditorDebuggerPlugin_method_get_sessions>` or get a specific one via :ref:`get_session<class_EditorDebuggerPlugin_method_get_session>`.
.. tabs::
.. code-tab:: gdscript
@tool
extends EditorPlugin
class ExampleEditorDebugger extends EditorDebuggerPlugin:
func _has_capture(prefix):
# Return true if you wish to handle message with this prefix.
return prefix == "my_plugin"
func _capture(message, data, session_id):
if message == "my_plugin:ping":
get_session(session_id).send_message("my_plugin:echo", data)
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"
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)
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`_capture<class_EditorDebuggerPlugin_private_method__capture>` **(** :ref:`String<class_String>` message, :ref:`Array<class_Array>` data, :ref:`int<class_int>` session_id **)** |virtual| |
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`_has_capture<class_EditorDebuggerPlugin_private_method__has_capture>` **(** :ref:`String<class_String>` capture **)** |virtual| |const| |
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`_setup_session<class_EditorDebuggerPlugin_private_method__setup_session>` **(** :ref:`int<class_int>` session_id **)** |virtual| |
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` | :ref:`get_session<class_EditorDebuggerPlugin_method_get_session>` **(** :ref:`int<class_int>` id **)** |
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`get_sessions<class_EditorDebuggerPlugin_method_get_sessions>` **(** **)** |
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_EditorDebuggerPlugin_private_method__capture:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **_capture** **(** :ref:`String<class_String>` message, :ref:`Array<class_Array>` data, :ref:`int<class_int>` session_id **)** |virtual|
Override this method to process incoming messages. The ``session_id`` is the ID of the :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` that received the message (which you can retrieve via :ref:`get_session<class_EditorDebuggerPlugin_method_get_session>`).
.. rst-class:: classref-item-separator
----
.. _class_EditorDebuggerPlugin_private_method__has_capture:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **_has_capture** **(** :ref:`String<class_String>` capture **)** |virtual| |const|
Override this method to enable receiving messages from the debugger. If ``capture`` is "my_message" then messages starting with "my_message:" will be passes to the :ref:`_capture<class_EditorDebuggerPlugin_private_method__capture>` method.
.. rst-class:: classref-item-separator
----
.. _class_EditorDebuggerPlugin_private_method__setup_session:
.. rst-class:: classref-method
void **_setup_session** **(** :ref:`int<class_int>` session_id **)** |virtual|
Override this method to be notified whenever a new :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` is created (the session may be inactive during this stage).
.. rst-class:: classref-item-separator
----
.. _class_EditorDebuggerPlugin_method_get_session:
.. rst-class:: classref-method
:ref:`EditorDebuggerSession<class_EditorDebuggerSession>` **get_session** **(** :ref:`int<class_int>` id **)**
Returns the :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` with the given ``id``.
.. rst-class:: classref-item-separator
----
.. _class_EditorDebuggerPlugin_method_get_sessions:
.. rst-class:: classref-method
:ref:`Array<class_Array>` **get_sessions** **(** **)**
Returns an array of :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` currently available to this debugger plugin.
\ **Note:** Sessions in the array may be inactive, check their state via :ref:`EditorDebuggerSession.is_active<class_EditorDebuggerSession_method_is_active>`.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`