- Home /
How to handle big world models in Unity
Hello Everyone,
I'm developing a game that has an extensive world model in the background:
- Solar System #1
- Planet #1
- Building #1
- Building #2
- ...
- Planet #2
- ...
- Solar System #2
- ...
- ...
A planet has different building types, has graphical representation (transform, mesh, etc).
Buildings are different, so I can not display them easily in the Editor as a polymorphic list.
My requirements are the following:
Being able to edit a Solar System in the Editor, save it into some loadable asset
Being able to have all Solar Systems in the memory as every now and then I need to make calculations on them to advance time, change population, etc.
Only 1 Solar System is displayed at a time.
Being able to save all systems into a savegame, restore it properly, even if the number of Planets or Buildings have changed.
Ability to handle ~100 Systems, up to ~10 Planets each, with ~10 Buildings on each of them.
My question is what kind of architecture should I use? I considered the following:
Planets are Gameobjects, Buildings are MonoBehaviours on them. Solar Systems are GameObjects with the planets saved as Prefabs. Easy to edit in Editor, save to prefab, but I do not want to load ~1000 planets with transforms, meshes etc unnecessarily. Also game save/load is tricky.
Planets are GameObjects, Buildings are Monobehaviours on them. Solar Systems are GameObjects with the planets, but they are saved into a text/binary file by an editor script, and can also be loaded from it. During Runtime I can load a Solar System as a lightweight model to handle the calculations on the unseen objects or as a displayed system. For save/load I can do the same: use the text/binary file as before. My problem with this solution is it feels like I'm not using Unity as it is intended.