How do I prevent a scene from being freed once I switch to a new scene, and back?

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

I have a program that has 10 scenes (grids) that are preloaded. I have code that changes scenes when a button is pressed. The code works and I am able to draw on what ever grid I want. The problem comes from the fact that the code, change scene(), seems to free the previous scene. For example, if I draw on the first grid, change to the second grid, then change back to the first, everything will be gone. I have been looking at ways to switch to multiple grids, but it has yet to work. I have found something called reload scene from path(), and save scene(). This is the link to where I have found it.

EditorInterface — Godot Engine (3.0) documentation in English

My question is, will any of those methods work? All I need to do is have the scene not be freed when I change the scene. I appreciate any help.

:bust_in_silhouette: Reply From: Brinux

While I’m actually have the opposite problem, queue_free is supposed to dump the previously loaded scene.

What you want is to merge your scenes together into one bigger tree.

I suggest create another scene (the trunk!), and which loads your other 10 into itself. You can do this in the Scene panel in Godot, or you can load it with script code with

onready var scene_loader = preload(“res://OneOfYourTenScenes.tscn”)

var s = scene_loader.instance()
add_child(s)

if you are running a Node2D setup, you can shuffle the z_index to flip the one you want to the front.
If you are running a Spacial setup, I would just move the camera to the one you want to work with.