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)