Creating new scenes at runtime and making them accessible

Hi guys,

I know that Unity has certain limitations when it comes to scene management, but I can hardly believe that the thing I want to achieve is simply not possible to realize.

In my game you can build structures, whereupon the inside area of these structures is generated automatically (in a new scene), so that you can enter them. You can build as many structures as you want, thus it should be possible to create an infinite amount of scenes with dynamically (via input parameters) generated content.

Now, when I use SceneManager.CreateScene, it won’t be added to build settings. And I’ve heard this isn’t even possible. But without the scene being in the build settings, it won’t load, nor can I access it in any way.

The only possible solution that comes to my mind is that you can maybe have like a predefined amount of empty scenes available that the player is not likely to reach (with the structures built), and to store a gameobject in them that can be referenced to - to make initialization possible and solve the issue with the build settings. But is this a wise thing to do? It feels not right.

Do you have any other / simpler ideas how to resolve this?
Thank you very much!

Is the content generated during runtime? Then you could simply have one scene where you dynamically load the content. The scene would only have one GameObject with a component that does the loading.

If the content is generated in editor, then you can create the scenes and add them to the build settings with this: Unity - Scripting API: EditorBuildSettings.scenes

Thank you for your answer! Basically, the content is generated during runtime. The problem with the ā€˜one scene solution’ is that I want the multiple scenes to run simultaneously (additively), because they represent inside and outside of a structure. Consequently, when the player enters a house for example, everything outside should remain as is, so overriding the scene with new content is not a feasible solution imo.

bump… if you have a hint for me, please let me know, it’s super important for me!

Similar problem here.
Anyone know more?

Don’t have the inside of the house as a scene. Instead, teleport the player to somewhere far enough from ā€œoutsideā€, and build a house from prefabs at runtime there.

2 Likes

Group dynamically created content for each ā€˜scene’ under its own parent game object, then disable/enable each of these game objects to display whichever ā€˜scene’ you want.

2 Likes