Godot Version
4.3
Question
Since Godot’s Editor itself consists of the same Control nodes one can use in-game, I was wondering if there is a way to have in-game UI interactions affect the Editor, or at the very least, affect EditorPlugins in the project as some sort of debugging tool.
Say I create a dock scene which is a Control node with a Label on it, and I attach it to the Editor like so:
@tool
extends EditorPlugin
var dock
func _enter_tree():
dock = preload("res://addons/mplugin/labeldock.tscn").instantiate()
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BL, dock)
func _exit_tree():
...
func update_text(new_text):
var label = dock.get_node("Label")
label.text = new_text
Now in a different scene which I would then run, I have a button that, when pressed, should access that dock and call update_text
.
@tool
extends Button
func _on_pressed():
var mplugin_dock
var editor_interface = EditorInterface...
..?
mplugin_dock.update_text("new data")
I have tried going through the EditorInterface
singleton inside the button script, which results in an Invalid call
whenever I try to call its methods, and am now stuck at how to access that dock, so I might be missing something very crucial and/or silly
Could you please explain how this would work, if at all? Thank you in advance!
P.S.
I agree that there would be better ways to design a debug tool that doesn’t necessarily go this route, so I partly ask this question also just to understand the Editor interface better, to check if something like this is at all possible with GDScript alone and what I would have to do if that is the case.