This scene is not loaded when the game starts running. This is a scene that is instantiated and added to the scene tree during runtime. Once the scene is added to the tree, using the “remote” tab of the editor, I can see the following scene tree nodes:
As you can see, the order is incorrect, which very much impacts how things are laid out. Also, importantly, the ownership is not retained. The UI components are not nested underneath “Content” Vertical Box as they should be.
Is there any way to address this? Is there something I’m missing? It seems like when add_child is called, it adds the Background->MarginContainer->Content UI nodes correctly and nested correctly. But then then remaining nodes are added as root level siblings. Is this some funkiness due to the scene inheritance?
Okay, I’ve posted the code below for posterity. Resources I found online seem to indicate this is the correct way, unless I’ve missed something?
NOTE: In this sample code, “path” is a PackedScene.
# Load next scene
# Instaniate scene
current_scene = path.instantiate()
# Add it to scene as a child of root
slide_content_node.add_child(current_scene)
I think this or something similar can happen when the base inherited scene changes and has overlapping names with the new nodes of the derived scene, maybe try re-saving your scenes.