I want to create a Plugin that adds a Control to the engine layout. This works fine. But I cannot pass a reference to EditorPlugin script that adds these Controls. I need to pass that reference because I want the Controls to be able to access functions that only a EditorPlugin can run ( geteditorinterface e.g.).
Minimal project to explain my problem:
The Control added by the plugin is a CenterContainer with a Button as a Child.
When the Button is clicked it is supposed to print the Plugin variable to the standardoutput.
The CenterContainer has the following script:
func _ready() -> void:
func _on_button_button_up() -> void:
print("plugin is: ",Plugin)
The Plugin has the following script:
@onready var PluginControl
func _enter_tree() -> void:
PluginControl = load("res://addons/LevelEditor/PluginControl.tscn").instantiate()
PluginControl.Plugin = self
func _exit_tree() -> void:
Neither does the ready func in Control print nor can the EditorPlugin assign self to the var Plugin in Control. It does not make a difference if it is a @onready var instead of var or if the EditorPlugin tries to assign it in its ready or init or entertree (as shown above).
How do you people make the EditorPlugin script interact with its Controls?
I appreciate you help :) Thanks!