Hi,
I've created an editor dock following this tutorial http://docs.godotengine.org/en/latest/tutorials/_plugins.html.
So far it contains only a button.
Now, I would like to access the scene_tree by pressing the button, for example, get the name of the current scene and print it to console, check if the scene contains a certain node, ...
How can I do that?
The dock is initialized through:
tool
extends EditorPlugin
var dock = null
func _enter_tree():
dock = preload("res://addons/dock/Dock.tscn").instance()
add_control_to_dock( DOCK_SLOT_RIGHT_UL, dock )
func _exit_tree():
remove_control_from_docks(dock)
if(dock!=null):
#dock.get_parent().remove_child(dock);
dock.free()
dock = null
The actual dock (Dock.tscn) has the following script attached:
tool
extends Control
var ep = null
func _enter_tree():
get_node("BUTTON").connect("pressed", self, "_test_stuff")
ep = EditorPlugin.new()
func _test_stuff():
var selection = ep.get_selection().get_selected_nodes()[0]
print( str(selection.get_name()) )