I've got two scenes, one with room 1 and one with room 2.

In room 1 I've got one table with two 3D assets on top of it. This room also has a door that connects to room 2 through a door but it's closed.

Once going near the 3D assets a dialog pops up saying to click "E". This pops up a 2D form one needs to fill.

Only after filling both forms I'm able to go into room 2.

Now what I would like to do is, depending on the response in the form, one or more duplicate room 2 scenes should be created and dynamically added to the scene. If with scenes isn't possible, what's the way to do such thing?

Know about SceneManager.CreateScene but this creates an empty scene, not exactly what I want to.

  • 2
    \$\begingroup\$ This problem seems to me like something I would solve with prefabs instead of scenes. I would create just one secene and make each room a prefab. Then depending on the decisions the player made I would decide which room prefabs to instantiate. Do you happen to have experience in the Godot engine? Most of the problems Godot solves by instantiating scenes is solved in Unity by instantiating prefabs. \$\endgroup\$
    – Philipp
    Commented Mar 26, 2020 at 9:38
  • \$\begingroup\$ I'm ok also with using prefabs, scenes were just an idea. \$\endgroup\$ Commented Mar 26, 2020 at 9:51
  • 1
    \$\begingroup\$ @Philipp I'd say that's worth posting as an answer. :) \$\endgroup\$
    – DMGregory
    Commented Mar 26, 2020 at 10:19

1 Answer 1


This problem seems to me like something I would solve with prefabs instead of scenes.

I would create just one scene for all rooms. Those rooms which appear in any case and always in the same position would be part of that scene. Those rooms which only appear conditionally would be prefabs.

The script which processes the player decisions in the form would get an inspector variable for each room it is able to spawn. I would then assign the room prefabs to those variables in the inspector and write the script to Instantiate the room prefabs according to the player's decisions.

Alternatively, if each room will always appear in the same position, you could make all the rooms part of the scene but set all the conditional rooms to inactive. The script would then have references to these rooms in the scene instead of references to prefabs. It would then activate the rooms you want in the game with room.SetActive(true). This approach has the advantage that you can mark the rooms as "static" which improves various performance metrics and that you might be able to use baked lightmaps (under some conditions), which can result in better looking lighting.

  • \$\begingroup\$ You can answer also here if you will. \$\endgroup\$ Commented Mar 26, 2020 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .