EditorDebuggerPlugin

package
v0.0.0-...-fa94a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

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.AddDebuggerPlugin.

Once added, the SetupSession 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 GetSessions or get a specific one via GetSession.

package main

import (
	"fmt"

	"graphics.gd/classdb/EditorDebuggerPlugin"
	"graphics.gd/classdb/EditorPlugin"
	"graphics.gd/classdb/Label"
)

type ExampleEditorDebuggerPlugin struct {
	EditorPlugin.Extension[ExampleEditorDebuggerPlugin]

	debugger *ExampleEditorDebugger
}

func NewExampleEditorDebuggerPlugin() *ExampleEditorDebuggerPlugin {
	return &ExampleEditorDebuggerPlugin{
		debugger: new(ExampleEditorDebugger),
	}
}

func (p *ExampleEditorDebuggerPlugin) EnterTree() {
	p.AsEditorPlugin().AddDebuggerPlugin(p.debugger.AsEditorDebuggerPlugin())
}

func (p *ExampleEditorDebuggerPlugin) ExitTree() {
	p.AsEditorPlugin().RemoveDebuggerPlugin(p.debugger.AsEditorDebuggerPlugin())
}

type ExampleEditorDebugger struct {
	EditorDebuggerPlugin.Extension[ExampleEditorDebugger]
}

func (d *ExampleEditorDebugger) HasCapture(capture string) bool {
	// Return true if you wish to handle messages with the prefix "my_plugin:".
	return capture == "my_plugin"
}

func (d *ExampleEditorDebugger) Capture(message string, data []any, sessionID int) bool {
	if message == "my_plugin:ping" {
		d.AsEditorDebuggerPlugin().GetSession(sessionID).MoreArgs().SendMessage("my_plugin:echo", data)
		return true
	}
	return false
}

func (d *ExampleEditorDebugger) SetupSession(sessionID int) {
	// Add a new tab in the debugger session UI containing a label.
	var label = Label.New()
	label.AsNode().SetName("Example plugin") // Will be used as the tab title.
	label.SetText("Example plugin")
	var session = d.AsEditorDebuggerPlugin().GetSession(sessionID)
	// Listens to the session started and stopped signals.
	session.OnStarted(func() { fmt.Println("Session started") })
	session.OnStopped(func() { fmt.Println("Session stopped") })
	session.AddSessionTab(label.AsControl())
}

To connect on the running game side, use the EngineDebugger singleton:

package main

import (
	"fmt"

	"graphics.gd/classdb/EngineDebugger"
	"graphics.gd/classdb/Node"
)

type ExampleDebuggerPlugin struct {
	Node.Extension[ExampleDebuggerPlugin]
}

func (e *ExampleDebuggerPlugin) Ready() {
	EngineDebugger.RegisterMessageCapture("my_plugin", func(message string, data []any) bool {
		// Note that the "my_plugin:" prefix is not used here.
		if message == "echo" {
			fmt.Println("Echo received:", data)
			return true
		}
		return false
	})
}

Note: While the game is running, @GlobalScope.Print and similar functions called in the editor do not print anything, the Output Log prints only game messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsEditorDebuggerPlugin() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsEditorDebuggerPlugin

func (self *Extension[T]) AsEditorDebuggerPlugin() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.EditorDebuggerPlugin

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsEditorDebuggerPlugin

func (self Instance) AsEditorDebuggerPlugin() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) GetSession

func (self Instance) GetSession(id int) EditorDebuggerSession.Instance

Returns the EditorDebuggerSession with the given 'id'.

func (Instance) GetSessions

func (self Instance) GetSessions() []EditorDebuggerSession.Instance

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

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

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Interface

type Interface interface {
	// Override this method to be notified whenever a new [EditorDebuggerSession] is created. Note that the session may be inactive during this stage.
	//
	// [EditorDebuggerSession]: https://pkg.go.dev/graphics.gd/classdb/EditorDebuggerSession
	SetupSession(session_id int)
	// 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.
	//
	// [Capture]: https://pkg.go.dev/graphics.gd/classdb/EditorDebuggerPlugin#Interface
	HasCapture(capture string) bool
	// Override this method to process incoming messages. The 'session_id' is the ID of the [EditorDebuggerSession] that received the 'message'. Use [GetSession] to retrieve the session. This method should return true if the message is recognized.
	//
	// [EditorDebuggerSession]: https://pkg.go.dev/graphics.gd/classdb/EditorDebuggerSession
	// [GetSession]: https://pkg.go.dev/graphics.gd/classdb/EditorDebuggerPlugin#Instance.GetSession
	Capture(message string, data []any, session_id int) bool
	// Override this method to be notified when a breakpoint line has been clicked in the debugger breakpoint panel.
	GotoScriptLine(script Script.Instance, line int)
	// Override this method to be notified when all breakpoints are cleared in the editor.
	BreakpointsClearedInTree()
	// Override this method to be notified when a breakpoint is set in the editor.
	BreakpointSetInTree(script Script.Instance, line int, enabled bool)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL