Parallel world handling - abstracting data from physics and drawing

I’d like to create a game that has a number of potential “spaces”, all drawn in the same place in Unity (IE without moving the camera), and to be able to swap between them, while still saving some state about these spaces. To make it less abstract, here are a few examples:

Suppose I’m making a puzzle platformer that has a “dream world” and a “real world”, and I want to switch between them, saving state in both - when I kill someone in the dream world and go to reality and back to dreams, the person remains dead.

As a more complicated example that more closely reflects what I’m trying to do, suppose there’s a roguelike or a strategy game or something that has some arbitrary number of “maps”, each of which can have any arbitrary state (player/unit positions, loot, level layout), which needs to be maintained even when that map isn’t loaded.

The first example could potentially be handled by having two cameras, or two layers, or something else. The second example is what I’d actually like to do, however. What would be the preferred, optimal way to handle this scenario, where I want to be able to get rid of meshes, colliders, and all of the other data that doesn’t directly apply to what’s being drawn at any given moment?

I’ve considered simply removing the gameobjects then re-instantiating them, but that sounds costly. Is there a better alternative?

You might consider having each “game state” be represented by an empty game object at the root of the hierarchy (positioned at (0,0,0)). All the objects within that state would then be a descendant of that particular game state.

Hierarchy
 |
 |- GameStateA
 |    |
 |    |- Enemy in State A
 |    |- Player in State A
 |
 |- GameStateB
 |    |
 |    |- Different enemy in State B
 |    |- Player in State B
 ...

Then you can manage which GameState is “active” by enabling or disabling the hierarchies. So, assuming you have gameStateA and gameStateB representing the top level objects you could set a particular game state with something like

gameStateA.SetActive(true);
gameStateB.SetActive(false);

You could also extend this to an arbitrary number of game states by storing them in a list.

SetActiveState(GameState target)
{
    foreach (GameState current in gameStates)
    {
        current.SetActive(current == target);
    }
}

Keep in mind that such a solution would keep all the GameObjects for all the states in memory. If GameStates take up a large amount a memory, or you plan on having a lot of GameStates, then you might want to consider serializing and deserializing Game States as suggested in a comment by tanoshimi.