class_editordebuggerplugin.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/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_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).
  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(capture):
  24. # Return true if you wish to handle messages with the prefix "my_plugin:".
  25. return capture == "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. return true
  30. return false
  31. func _setup_session(session_id):
  32. # Add a new tab in the debugger session UI containing a label.
  33. var label = Label.new()
  34. label.name = "Example plugin" # Will be used as the tab title.
  35. label.text = "Example plugin"
  36. var session = get_session(session_id)
  37. # Listens to the session started and stopped signals.
  38. session.started.connect(func (): print("Session started"))
  39. session.stopped.connect(func (): print("Session stopped"))
  40. session.add_session_tab(label)
  41. var debugger = ExampleEditorDebugger.new()
  42. func _enter_tree():
  43. add_debugger_plugin(debugger)
  44. func _exit_tree():
  45. remove_debugger_plugin(debugger)
  46. To connect on the running game side, use the :ref:`EngineDebugger<class_EngineDebugger>` singleton:
  47. .. tabs::
  48. .. code-tab:: gdscript
  49. extends Node
  50. func _ready():
  51. EngineDebugger.register_message_capture("my_plugin", _capture)
  52. EngineDebugger.send_message("my_plugin:ping", ["test"])
  53. func _capture(message, data):
  54. # Note that the "my_plugin:" prefix is not used here.
  55. if message == "echo":
  56. prints("Echo received:", data)
  57. return true
  58. return false
  59. \ **Note:** While the game is running, :ref:`@GlobalScope.print<class_@GlobalScope_method_print>` and similar functions *called in the editor* do not print anything, the Output Log prints only game messages.
  60. .. rst-class:: classref-reftable-group
  61. Methods
  62. -------
  63. .. table::
  64. :widths: auto
  65. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | |void| | :ref:`_breakpoint_set_in_tree<class_EditorDebuggerPlugin_private_method__breakpoint_set_in_tree>`\ (\ script\: :ref:`Script<class_Script>`, line\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) |virtual| |
  67. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | |void| | :ref:`_breakpoints_cleared_in_tree<class_EditorDebuggerPlugin_private_method__breakpoints_cleared_in_tree>`\ (\ ) |virtual| |
  69. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`_capture<class_EditorDebuggerPlugin_private_method__capture>`\ (\ message\: :ref:`String<class_String>`, data\: :ref:`Array<class_Array>`, session_id\: :ref:`int<class_int>`\ ) |virtual| |
  71. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | |void| | :ref:`_goto_script_line<class_EditorDebuggerPlugin_private_method__goto_script_line>`\ (\ script\: :ref:`Script<class_Script>`, line\: :ref:`int<class_int>`\ ) |virtual| |
  73. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`_has_capture<class_EditorDebuggerPlugin_private_method__has_capture>`\ (\ capture\: :ref:`String<class_String>`\ ) |virtual| |const| |
  75. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | |void| | :ref:`_setup_session<class_EditorDebuggerPlugin_private_method__setup_session>`\ (\ session_id\: :ref:`int<class_int>`\ ) |virtual| |
  77. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` | :ref:`get_session<class_EditorDebuggerPlugin_method_get_session>`\ (\ id\: :ref:`int<class_int>`\ ) |
  79. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Array<class_Array>` | :ref:`get_sessions<class_EditorDebuggerPlugin_method_get_sessions>`\ (\ ) |
  81. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Method Descriptions
  86. -------------------
  87. .. _class_EditorDebuggerPlugin_private_method__breakpoint_set_in_tree:
  88. .. rst-class:: classref-method
  89. |void| **_breakpoint_set_in_tree**\ (\ script\: :ref:`Script<class_Script>`, line\: :ref:`int<class_int>`, enabled\: :ref:`bool<class_bool>`\ ) |virtual| :ref:`🔗<class_EditorDebuggerPlugin_private_method__breakpoint_set_in_tree>`
  90. Override this method to be notified when a breakpoint is set in the editor.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_EditorDebuggerPlugin_private_method__breakpoints_cleared_in_tree:
  94. .. rst-class:: classref-method
  95. |void| **_breakpoints_cleared_in_tree**\ (\ ) |virtual| :ref:`🔗<class_EditorDebuggerPlugin_private_method__breakpoints_cleared_in_tree>`
  96. Override this method to be notified when all breakpoints are cleared in the editor.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_EditorDebuggerPlugin_private_method__capture:
  100. .. rst-class:: classref-method
  101. :ref:`bool<class_bool>` **_capture**\ (\ message\: :ref:`String<class_String>`, data\: :ref:`Array<class_Array>`, session_id\: :ref:`int<class_int>`\ ) |virtual| :ref:`🔗<class_EditorDebuggerPlugin_private_method__capture>`
  102. Override this method to process incoming messages. The ``session_id`` is the ID of the :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` that received the ``message``. Use :ref:`get_session<class_EditorDebuggerPlugin_method_get_session>` to retrieve the session. This method should return ``true`` if the message is recognized.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_EditorDebuggerPlugin_private_method__goto_script_line:
  106. .. rst-class:: classref-method
  107. |void| **_goto_script_line**\ (\ script\: :ref:`Script<class_Script>`, line\: :ref:`int<class_int>`\ ) |virtual| :ref:`🔗<class_EditorDebuggerPlugin_private_method__goto_script_line>`
  108. Override this method to be notified when a breakpoint line has been clicked in the debugger breakpoint panel.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_EditorDebuggerPlugin_private_method__has_capture:
  112. .. rst-class:: classref-method
  113. :ref:`bool<class_bool>` **_has_capture**\ (\ capture\: :ref:`String<class_String>`\ ) |virtual| |const| :ref:`🔗<class_EditorDebuggerPlugin_private_method__has_capture>`
  114. 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.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_EditorDebuggerPlugin_private_method__setup_session:
  118. .. rst-class:: classref-method
  119. |void| **_setup_session**\ (\ session_id\: :ref:`int<class_int>`\ ) |virtual| :ref:`🔗<class_EditorDebuggerPlugin_private_method__setup_session>`
  120. Override this method to be notified whenever a new :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` is created. Note that the session may be inactive during this stage.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_EditorDebuggerPlugin_method_get_session:
  124. .. rst-class:: classref-method
  125. :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` **get_session**\ (\ id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_EditorDebuggerPlugin_method_get_session>`
  126. Returns the :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` with the given ``id``.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_EditorDebuggerPlugin_method_get_sessions:
  130. .. rst-class:: classref-method
  131. :ref:`Array<class_Array>` **get_sessions**\ (\ ) :ref:`🔗<class_EditorDebuggerPlugin_method_get_sessions>`
  132. Returns an array of :ref:`EditorDebuggerSession<class_EditorDebuggerSession>` currently available to this debugger plugin.
  133. \ **Note:** Sessions in the array may be inactive, check their state via :ref:`EditorDebuggerSession.is_active<class_EditorDebuggerSession_method_is_active>`.
  134. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  135. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  136. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  137. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  138. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  139. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  140. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  141. .. |void| replace:: :abbr:`void (No return value.)`