Here is basically the code I'm using (I removed all "position" related args everywhere as I don't need them and it was not compatible with 2D)
const GROUPS := [
"Foreground",
"UI",
"Background",
]
const SLEEP_MSEC := 100
func _init():
SceneAdder._sleep_msec = 100
SceneAdder.set_groups(GROUPS)
func async_load(path,type,to_assign=null):
yield(get_tree(),"idle_frame")
var target
match type:
"canvas":
target = canvas_layer
"background":
target = background
"foreground":
target = foreground
"middle":
target = middle
if to_assign == null:
SceneLoader.load_scene_async(target, path)
else:
SceneLoader.load_scene_async_with_cb(target, path, funcref(self, "handle_load_callback"), {"type":type,"to_assign":to_assign})
func handle_load_callback(path : String, instance : Node, data : Dictionary) -> void:
propagate_call("add_"+data.type,[instance])
match data.to_assign:
"fight_scene":
fight_scene = instance
"codex":
codex = instance