How to connect to Remote Tree from Editor?

Godot Version

Godot v4.2.1 .NET 8

Question

A have a custom Editor Window, that i want to show some runtime debug information
So I have the EditorPlugin class and the window’s class

#if TOOLS
using Godot;

namespace Entitas.Generic.Editor;

[Tool]
public partial class VisualDebuggerLoader : EditorPlugin
{
	private Control _root;

	public override void _EnterTree()
	{
		_root = new VisualDebuggerWindow();
		_root.Name = nameof(VisualDebuggerWindow);

		AddControlToDock(DockSlot.LeftUr, _root);
	}

	public override void _ExitTree()
	{
		RemoveControlFromDocks(_root);
		_root.QueueFree();
	}
}
#endif
#if DEBUG || DEVELOPMENT_BUILD
using Godot;

namespace Entitas.Generic.Editor;

#if TOOLS
[Tool]
#endif
public partial class VisualDebuggerWindow : Control
{
	private Label _label;

	public override void _Ready()
	{
		_label = new Label();
		AddChild(_label);
	}

	public override void _Process(double delta)
	{
		var isRemoteTreeRunning = TODO;
		_label.Text = isRemoteTreeRunning
			? "The project isn't running"
			: "The remote tree is live!";
	}
}
#endif

But there is the question: How to check if the Game is actually running?
Engine.EditorHint doesn’t work in my case, because, as i understand, the code of the VisualDebuggerWindow is always running in the editor

I need something like Remote in Scene Dock but I couldn’t find anything>_<

Thanks in advance!

2 Likes

Did you figure out how to do this?

I wasn’t able to access the remote nodes in an editor plugin but I was able to send data back to a plugin by using this code in the game code:

EngineDebugger.SendMessage("mimic_custom:the_data", data);

and this code on the plugin side to receive it:

[Tool]
public partial class MimicGameStateInspector : EditorPlugin
{
    private MimicEditorDebugPlugin _debugger;

    public override void _EnterTree () {
        _debugger = new MimicEditorDebugPlugin();
        AddDebuggerPlugin(_debugger);

        _debugger.OnActorDataDelegate += OnActorData;
    }

    private void OnActorData (Array data) {
        // Do something with data here
    }

    public override void _ExitTree () {
        RemoveDebuggerPlugin(_debugger);
    }
}

public partial class MimicEditorDebugPlugin : EditorDebuggerPlugin
{
    public delegate void OnActorData (Array data);

    public OnActorData OnActorDataDelegate;

    public override bool _HasCapture (string capture) {
        if (capture == "mimic_custom") {
            return true;
        }
        return false;
    }

    public override bool _Capture (string message, Array data, int sessionId) {
        if (message == "mimic_custom:the_data") {
            OnActorDataDelegate?.Invoke(data);
        }
        return true;
    }
}

I wonder if the 4.4 changes will make it easier to access the remote node tree :thinking: