Editor tree vs Game tree for EditorPlugins

Godot Version

4.3

Question

Hello,

I’m learning EditorPlugins and I have a hard time understanding in which “tree” they are living, and how it relates to the game tree.

Here is my little experiment. I guess it is a misuse of the EditorPlugin, but I take that as an opportunity to understand better this relationship.

I create an editor plugin that has a certain static variable. In the plugin code I modify it and print it repeatedly (here to increase it at each physics tick)

@tool
class_name MyPlugin extends EditorPlugin

static var counter : int = 0

func _physics_process(delta: float) -> void:
	counter += 1
	print("From MyPlugin " + str(counter))

In my game code I also access that static variable, I modify it and print it (here to decrease it at each tick)

extends Node2D

func _physics_process(delta):
	MyPlugin.counter -= 1
	print("From Game " + str(MyPlugin.counter))

What I get when I run the game is this

It looks like the editor plugin and the game both have their independent copy of the same static variable…which is unexpected for a static variable !

I guess this is normal behavior and it has something to do with the tree they belong to ?

I understand that the editor plugin belongs to the editor tree, which is not the game remote tree. Does that explain why they don’t share the static variable ?

Still is there a way for those two trees to communicate and share information ? (pretty much what happens with the inspector)

Exactly! the game and editor are different processes. They do not share eachothers memory.

There is communication happening on the debug server between the editor and game instance but im not sure what is available to that interface.

Maybe you can try a debugger plugin i dont know whats possible

Maybe the game can send a message to the editor through the EngineDebugger and the editor can set the count on the editor plugin instance.

Thanks for confirming !

I’ll look into debugger and inspector plugin, and see if I can get a better understanding.

I wonder if there is a systematic classification of plugins.

I see that EditorPlugin derives from Node while other types of plugins (EditorInspectorPlugin, EditorDebuggerPlugin, and more) inherits from RefCounted. So it means there is no “base class” for plugins, so I have hard time mapping the space of possible plugins.