A Godot addon that facilitates bidirectional communication between the Godot Editor and the running game instance (Runtime).
addons/editorruntime folder to your project’s addons/ directory.Inherit from RuntimeMessage in Aspecty.EditorRuntime.Common.Messages:
public class MyCustomMessage : RuntimeMessage
{
public override string Command => "my_custom_command";
public int Value { get; set; }
public override Godot.Collections.Array Serialize()
{
return new Godot.Collections.Array { Value };
}
public override void Deserialize(Godot.Collections.Array data)
{
Value = data[0].AsInt32();
}
}
Implement IMessageHandler<T> to automatically handle specific message types:
using Godot;
using Aspecty.EditorRuntime.Runtime;
using YourNamespace.Messages;
public class MyCustomHandler : IMessageHandler<MyCustomMessage>
{
public void Handle(MyCustomMessage message, RuntimeBridge bridge)
{
GD.Print($"Received value: {message.Value}");
// Optionally send a response
bridge.Send(new ResponseMessage { Result = "OK" });
}
}
Auto-Discovery: Handlers are automatically discovered and registered via reflection. Just implement the interface and the system will find it!
Or manually register custom handlers:
public override void _Ready()
{
RuntimeBridge.Instance?.RegisterHandler(new MyCustomHandler());
}
RuntimeBridge.Instance.Send(new MyCustomMessage { Value = 42 });
private void OnMessageReceived(string command, Godot.Collections.Array data)
{
if (RuntimeBridge.Instance.TryDeserialize(command, data, out MyCustomMessage msg))
{
GD.Print($"Received value: {msg.Value}");
}
}
// In your EditorPlugin or Tool script
_debuggerPlugin.Broadcast(new MyCustomMessage { Value = 100 });
Editor Game
┌──────────────────┐ ┌──────────────────┐
│ EditorRuntimePlugin │ RuntimeBridge │
│ (Tool Plugin) │ (Autoload) │
├──────────────────┤ ├──────────────────┤
│ RuntimeDebugger │◄─────────►│ EngineDebugger │
│ Plugin │ Messages │ MessageCapture │
│ │ │ │
│ Command Buttons │ │ MessageHandlers │
│ Tabs & Logs │ │ (Auto-Discovery) │
└──────────────────┘ └──────────────────┘
IMessageHandler<T>.