You want to split your game objects into two: One that is to visualize the object in the world (contains all the renderer, meshes, materials and stuff) and another that execute the pure game logic (like moving around, deciding to attack, and all kinds of game decissions).
The pure game logic object usually does not have any “heavy” resources like textures, animations or meshes referenced, so you can easily load it into any scene without running out of memory.
This way, any scene can actually execute the logical game world progress, but only the scene you are currently want to be visible contains the “heavy” visualization.
Typically, these game logic objects are all in one big scene which then loads the “visualization scenes” using AddSceneAdditive.
Edit: To summarize it with an example, lets say “A station that should produce fuel all the time” ^^.
You got two classes for this station (all code is written on the fly totally untested - just to give you an idea)
class FuelProducingStationLogic : MonoBehaviour
{
public float fuelCurrent, fuelMax;
public float fuelProductionPerSecond;
void Update()
{
fuelCurrent = Math.Min(fuelMax, fuelCurrent + fuelProductionPerSecond * Time.deltaTime);
}
}
This component is attached to a gameObject with the name… lets say “FuelStationAlphaOmega01_sectorCentauri” ;). This gameObject is in the “main” scene and loaded all the time, so the Update function is called regardless where your ship is.
Now you got another component - lets call it FuelProducingStationVisual
class FuelProducingStationVisual : MonoBehaviour
{
FuelProducingStationLogic data;
void Awake() { data = SomeMagicToFindMyLogic(); }
public Material fillMaterial;
void Update()
{
fillMaterial.color = Color.Lerp(Color.red, Color.green, data.fuelCurrent/data.fuelMax);
}
}
Lets say this component is attached to a gameObject called FuelStationAlphaOmega01_sectorCentauri_Visual. The gameObject has the tag “VisualOnly”.
The “graphical” (or better “visual”) component does not produce fuel. But it knows hot to visualize the fuel in the scene - in my example by lerping a material from green to red.
Once you enter the sector where the fuel station belongs to, you load additive the scene “sectorCentauri.unity” which contains the gameObject FuelStationAlphaOmega01_sectorCentauri_Visual.
When you leave the sector, you simply destroy all game objects with the tag “VisualOnly”
Some final comments:
First, you usually don’t have an one-to-one mapping of logic classes and visualization classes. For example, the logic behind bullets moving are routinely covered by the shooting turret itself.
Also, sometimes the gameObjects labelled “visual” actually contain some logic. Especially things like the Physics system is usually not emulated in the pure logic code but fed from collision callbacks from the visual gameObjects. This means, that you have different behaviour in simulation whether you are present with your ship or not. That is perfectly normal for many bigger games. (AI calculations usually cheats if you are not there… like not actually tracing a grenade through the air to see if it hits but just throwing some random dice ;)).
Finally, if you just need some very small part of your economy simulated “while not there”, you need only handle that part of the simulation in logic classes. In our example above, if you can live with just having the production facilities running while not in a sector, but actual gunning dog fights are not need to happen accurately while not in the zone, there is no reason to have logic classes for ships, turrets, bullets and whatsoever. You still can randomly … e.g. place some ship debris when the player enters a zone after some time to give the illusion of a past heavy fight.