- Home /
How do you make a script that creates a new scene on runtime?
I would like to make a script that has sort of a scene prefab that is created for a new world, is there any way to do this in unity? Also, do the scenes in unity save changes you have made to them in the built version of your game? (like instantiated objects)
Answer by Jean-Fabre · May 09, 2011 at 05:48 AM
Hi,
For this, I use an empty scene as a template and build the content based on what need ( can be predefined, can be hardcoded, can be several small scenes I additively load anyway you want to store the definition of the content you need to show basically).
Check this question and answer, it explains one way to achieve what you want to achieve AND as a bonus be sure to have the garbage collector working on iOS.
Bye,
Jean
One thing I am confused about though is if, in my unity game, I am building something with cubes, does unity automatically save all of my instantiated cubes to the scene or do I have to manually do that? I think that this would help me solve my problem a bit, thanks!
yes, It's all saved in the scene ( everything that is in the hierarchy panel). If you want to reuse say one of your cube in another scene, then you should into prefabs, which allows you to make reusable component within the same scene and or amongst several distinct scenes.