How to save a scene and all it's descendent instanced scenes with a dynamically added resource?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By moinqidw

Download the zip at the bottom to checkout the reproduceable example project. This project is a short setup I created specifically to demonstrate essentially what I am trying to do. I will assume you can open the project and hence reference nodes/stuff from it in the below explanation.

I am creating scene instances and adding them into my scene tree through code, those scenes themselves will add other scenes to the scene tree also through code. As in the project, I have a main scene, which on ready adds a instance of the child scene, which has a child spatial node with a script that creates an instance of the grandchild scene and adds that as a child. This grandchild has a event handler such that when the mouse key is pressed it adds a cube mesh instance.

If I first press the mouse key, the cube appears. Now if I try to save the root scene with all the child nodes having set their owner to the root node, the resulting packed scene does not have the cube mesh. If I run the saved scene I simply see empty space. I would like the cube to actually get saved as well as it is part of the scene tree and I am setting the owner to the node that is being packed and saved.

Any help is greatly appreciated.
Example zip

The example project has compiled scripts, so it’s not possible to read the code you’re using.

Have you followed the mini-tutorial on PackedScene on how to save a node?

Ev1lbl0w | 2021-08-26 09:59