Index · Object → RefCounted → EditorDebuggerPlugin

EditorDebuggerPlugin

A base class to implement debugger plugins.

Class 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 EditorPlugin.add_debugger_plugin().

Once added, the _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).

You can retrieve the available EditorDebuggerSessions via get_sessions() or get a specific one via get_session().

@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 EngineDebugger singleton:

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, print() and similar functions called in the editor do not print anything, the Output Log prints only game messages.

Methods

func _breakpoint_set_in_tree(script: Script, line: int, enabled: bool) -> void

Override this method to be notified when a breakpoint is set in the editor.

func _breakpoints_cleared_in_tree() -> void

Override this method to be notified when all breakpoints are cleared in the editor.

func _capture(message: String, data: Array, session_id: int) -> bool

Override this method to process incoming messages. The session_id is the ID of the EditorDebuggerSession that received the message. Use get_session() to retrieve the session. This method should return true if the message is recognized.

func _goto_script_line(script: Script, line: int) -> void

Override this method to be notified when a breakpoint line has been clicked in the debugger breakpoint panel.

func _has_capture(capture: String) -> bool

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 _capture() method.

func _setup_session(session_id: int) -> void

Override this method to be notified whenever a new EditorDebuggerSession is created. Note that the session may be inactive during this stage.

func get_session(id: int) -> EditorDebuggerSession

Returns the EditorDebuggerSession with the given id.

func get_sessions() -> Array

Returns an array of EditorDebuggerSession currently available to this debugger plugin.

Note: Sessions in the array may be inactive, check their state via EditorDebuggerSession.is_active().

Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)