Debian Codegraph @

doc/classes/EditorDebuggerPlugin.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="EditorDebuggerPlugin" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A base class to implement debugger plugins.
5 </brief_description>
6 <description>
7 [EditorDebuggerPlugin] provides functions related to the editor side of the debugger.
8 To interact with the debugger, an instance of this class must be added to the editor via [method EditorPlugin.add_debugger_plugin].
9 Once added, the [method _setup_session] callback will be called for every [EditorDebuggerSession] available to the plugin, and when new ones are created (the sessions may be inactive during this stage).
10 You can retrieve the available [EditorDebuggerSession]s via [method get_sessions] or get a specific one via [method get_session].
11 [codeblocks]
12 [gdscript]
13 @tool
14 extends EditorPlugin
15
16 class ExampleEditorDebugger extends EditorDebuggerPlugin:
17
18 func _has_capture(capture):
19 # Return true if you wish to handle messages with the prefix "my_plugin:".
20 return capture == "my_plugin"
21
22 func _capture(message, data, session_id):
23 if message == "my_plugin:ping":
24 get_session(session_id).send_message("my_plugin:echo", data)
25 return true
26 return false
27
28 func _setup_session(session_id):
29 # Add a new tab in the debugger session UI containing a label.
30 var label = Label.new()
31 label.name = "Example plugin" # Will be used as the tab title.
32 label.text = "Example plugin"
33 var session = get_session(session_id)
34 # Listens to the session started and stopped signals.
35 session.started.connect(func (): print("Session started"))
36 session.stopped.connect(func (): print("Session stopped"))
37 session.add_session_tab(label)
38
39 var debugger = ExampleEditorDebugger.new()
40
41 func _enter_tree():
42 add_debugger_plugin(debugger)
43
44 func _exit_tree():
45 remove_debugger_plugin(debugger)
46 [/gdscript]
47 [/codeblocks]
48 To connect on the running game side, use the [EngineDebugger] singleton:
49 [codeblocks]
50 [gdscript]
51 extends Node
52
53 func _ready():
54 EngineDebugger.register_message_capture("my_plugin", _capture)
55 EngineDebugger.send_message("my_plugin:ping", ["test"])
56
57 func _capture(message, data):
58 # Note that the "my_plugin:" prefix is not used here.
59 if message == "echo":
60 prints("Echo received:", data)
61 return true
62 return false
63 [/gdscript]
64 [/codeblocks]
65 [b]Note:[/b] While the game is running, [method @GlobalScope.print] and similar functions [i]called in the editor[/i] do not print anything, the Output Log prints only game messages.
66 </description>
67 <tutorials>
68 </tutorials>
69 <methods>
70 <method name="_breakpoint_set_in_tree" qualifiers="virtual">
71 <return type="void" />
72 <param index="0" name="script" type="Script" />
73 <param index="1" name="line" type="int" />
74 <param index="2" name="enabled" type="bool" />
75 <description>
76 Override this method to be notified when a breakpoint is set in the editor.
77 </description>
78 </method>
79 <method name="_breakpoints_cleared_in_tree" qualifiers="virtual">
80 <return type="void" />
81 <description>
82 Override this method to be notified when all breakpoints are cleared in the editor.
83 </description>
84 </method>
85 <method name="_capture" qualifiers="virtual">
86 <return type="bool" />
87 <param index="0" name="message" type="String" />
88 <param index="1" name="data" type="Array" />
89 <param index="2" name="session_id" type="int" />
90 <description>
91 Override this method to process incoming messages. The [param session_id] is the ID of the [EditorDebuggerSession] that received the [param message]. Use [method get_session] to retrieve the session. This method should return [code]true[/code] if the message is recognized.
92 </description>
93 </method>
94 <method name="_goto_script_line" qualifiers="virtual">
95 <return type="void" />
96 <param index="0" name="script" type="Script" />
97 <param index="1" name="line" type="int" />
98 <description>
99 Override this method to be notified when a breakpoint line has been clicked in the debugger breakpoint panel.
100 </description>
101 </method>
102 <method name="_has_capture" qualifiers="virtual const">
103 <return type="bool" />
104 <param index="0" name="capture" type="String" />
105 <description>
106 Override this method to enable receiving messages from the debugger. If [param capture] is "my_message" then messages starting with "my_message:" will be passed to the [method _capture] method.
107 </description>
108 </method>
109 <method name="_setup_session" qualifiers="virtual">
110 <return type="void" />
111 <param index="0" name="session_id" type="int" />
112 <description>
113 Override this method to be notified whenever a new [EditorDebuggerSession] is created. Note that the session may be inactive during this stage.
114 </description>
115 </method>
116 <method name="get_session">
117 <return type="EditorDebuggerSession" />
118 <param index="0" name="id" type="int" />
119 <description>
120 Returns the [EditorDebuggerSession] with the given [param id].
121 </description>
122 </method>
123 <method name="get_sessions">
124 <return type="Array" />
125 <description>
126 Returns an array of [EditorDebuggerSession] currently available to this debugger plugin.
127 [b]Note:[/b] Sessions in the array may be inactive, check their state via [method EditorDebuggerSession.is_active].
128 </description>
129 </method>
130 </methods>
131 </class>