on startup, I want to get some objects in the scene, for my editor plugin

@tool
extends EditorPlugin
func _enter_tree():
      var Scene = EditorInterface.get_edited_scene_root()
      print( "scene = " + str(Scene) )

this usually works fine, but if the plugin is already open when Godot is launched, the plugin seems to not yet register the loaded scene. it print “Scene = null” !!
also, if we switch scenes, the plugin needs to register the changed current scene. How do I do this?
how do I get the current scene in editor interface, and update it on scene change or once scene is loaded to make sure we are working with the correct nodes in the correct scene?

I mean, I could do this:

func _process(delta):
      var Scene = EditorInterface.get_edited_scene_root()
      print( "scene =  " + str(Scene) )

but that seems repetitive and unnecessary. surely I could only update the the variable with out scene root on scene change to get the nodes within? only once instead of repetitively??

ive been looking into the EditorPlugin.scene_changed but cant seem to get it working!

func _enter_tree():
	EditorPlugin.scene_changed.connect(scene_changed)
func scene_changed ( ):
	var Scene = EditorInterface.get_edited_scene_root()
	print( "scene changed -> " + str(Scene) )

give me error " Invalid get index ‘scene_changed’ "

func _enter_tree():
	scene_changed.connect(scene_changed)
func scene_changed ( ):
	var Scene = EditorInterface.get_edited_scene_root()
	print( "scene changed -> " + str(Scene) )

"cannot find property ‘connect’ on ‘callable’

what am I missing?

    12 days later

    Sander87 by declaring a func scene_changed(): ... you are overriding the signal. Try with a different function name.