class_editordebuggerplugin.rst 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/EditorDebuggerPlugin.xml.
  6. .. _class_EditorDebuggerPlugin:
  7. EditorDebuggerPlugin
  8. ====================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A base class to implement debugger plugins.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **EditorDebuggerPlugin** provides functions related to the editor side of the debugger.
  15. 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>`.
  16. Once added, the :ref:`_setup_session<class_EditorDebuggerPlugin_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).
  17. 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>`.
  18. .. tabs::
  19. .. code-tab:: gdscript
  20. @tool
  21. extends EditorPlugin
  22. class ExampleEditorDebugger extends EditorDebuggerPlugin:
  23. func _has_capture(prefix):
  24. # Return true if you wish to handle message with this prefix.
  25. return prefix == "my_plugin"
  26. func _capture(message, data, session_id):
  27. if message == "my_plugin:ping":
  28. get_session(session_id).send_message("my_plugin:echo", data)
  29. func _setup_session(session_id):
  30. # Add a new tab in the debugger session UI containing a label.
  31. var label = Label.new()
  32. label.name = "Example plugin"
  33. label.text = "Example plugin"
  34. var session = get_session(session_id)
  35. # Listens to the session started and stopped signals.
  36. session.started.connect(func (): print("Session started"))
  37. session.stopped.connect(func (): print("Session stopped"))
  38. session.add_session_tab(label)
  39. var debugger = ExampleEditorDebugger.new()
  40. func _enter_tree():
  41. add_debugger_plugin(debugger)
  42. func _exit_tree():
  43. remove_debugger_plugin(debugger)
  44. .. rst-class:: classref-reftable-group
  45. Methods
  46. -------
  47. .. table::
  48. :widths: auto
  49. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`_capture<class_EditorDebuggerPlugin_method__capture>` **(** :ref:`String<class_String>` message, :ref:`Array<class_Array>` data, :ref:`int<class_int>` session_id **)** |virtual| |
  51. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`_has_capture<class_EditorDebuggerPlugin_method__has_capture>` **(** :ref:`String<class_String>` capture **)** |virtual| |const| |
  53. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`_setup_session<class_EditorDebuggerPlugin_method__setup_session>` **(** :ref:`int<class_int>` session_id **)** |virtual| |
  55. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` | :ref:`get_session<class_EditorDebuggerPlugin_method_get_session>` **(** :ref:`int<class_int>` id **)** |
  57. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Array<class_Array>` | :ref:`get_sessions<class_EditorDebuggerPlugin_method_get_sessions>` **(** **)** |
  59. +-----------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. .. rst-class:: classref-section-separator
  61. ----
  62. .. rst-class:: classref-descriptions-group
  63. Method Descriptions
  64. -------------------
  65. .. _class_EditorDebuggerPlugin_method__capture:
  66. .. rst-class:: classref-method
  67. :ref:`bool<class_bool>` **_capture** **(** :ref:`String<class_String>` message, :ref:`Array<class_Array>` data, :ref:`int<class_int>` session_id **)** |virtual|
  68. 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>`).
  69. .. rst-class:: classref-item-separator
  70. ----
  71. .. _class_EditorDebuggerPlugin_method__has_capture:
  72. .. rst-class:: classref-method
  73. :ref:`bool<class_bool>` **_has_capture** **(** :ref:`String<class_String>` capture **)** |virtual| |const|
  74. 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_method__capture>` method.
  75. .. rst-class:: classref-item-separator
  76. ----
  77. .. _class_EditorDebuggerPlugin_method__setup_session:
  78. .. rst-class:: classref-method
  79. void **_setup_session** **(** :ref:`int<class_int>` session_id **)** |virtual|
  80. Override this method to be notified whenever a new :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` is created (the session may be inactive during this stage).
  81. .. rst-class:: classref-item-separator
  82. ----
  83. .. _class_EditorDebuggerPlugin_method_get_session:
  84. .. rst-class:: classref-method
  85. :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` **get_session** **(** :ref:`int<class_int>` id **)**
  86. Returns the :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` with the given ``id``.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_EditorDebuggerPlugin_method_get_sessions:
  90. .. rst-class:: classref-method
  91. :ref:`Array<class_Array>` **get_sessions** **(** **)**
  92. Returns an array of :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` currently available to this debugger plugin.
  93. Note: Not sessions in the array may be inactive, check their state via :ref:`EditorDebuggerSession.is_active<class_EditorDebuggerSession_method_is_active>`
  94. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  95. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  96. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  97. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  98. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  99. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`