After spawning a node at run-time, is there a way to make it persist in the editor when you exit the game?

Godot Version

Godot 4.2.2

Question

During running of my game, I am spawning nodes to create a dungeon through procedural generation. If I exit the game, then all those spawned nodes go away. Is there a way to make them stay in the editor?

If you are procedurally generating your levels, the way to go is to store the generation data in a file like json so you can read the data in to regenerate the level at runtime.

However, another way you can do it is to store your scene as a packed scene after generating it, then you can open the scene from your file manager. I’ve not tried this before, but it should work, probably with some downsides.

Yes, I have all that.

What I’m hoping to have is the level continuing in the editor UI after I close the app.

This is not an answer to your question and you may already know this but…
When testing random you want to repeat the random numbers until you are completed debugging.
Use seed(n) and the random numbers generated will be the same sequence when n is repeated.
For example, if seed(1) random numbers generated are 5, 7, 1, 4, 1 then each time you use 1 as the seed value that same set of numbers will be generated.
So if you are proceduraly generating rooms via random, use the seed() function to repeat the exact same room that you want to test.

Best answer I’ve been able to come up with:

@Tool scripting to run code in the editor. Instead of preserving run-time spawns, call that code from an in-editor script.

If I do get this to work, I should probably post details and what, how, and why I’m doing this.