I have a function to swap scenes in a singleton
But I want to add a CanvasLayer on every new Scene which I'm using it as a Debugger Overlay.
To add it as a child of the loaded scene I have a function on every Scene Main node
var DebugOverlay = load("res://Scenes/DebugOverlay.tscn").instance()
This requires me to create an script on scene and add this function.
I was trying to simplify this process using function and calling it in
change_scene after the
var scene_tree = str(get_tree().get_current_scene())
var scene_name =str(get_tree().get_current_scene().get_name())
But what I get is the info of the last scene instead of the new one.
What would be a solution to this problem? Is there something I can use to tell when the next scene is ready and access that information from the singleton?
I know I could just add the CanvasLayer.tscn in every scene in the editor but I would like to understand better how this process works