Prefab or Scene Base Game Development
I have few questions related to overall game structure in Unity because during my experience time I have seen many developers code but all have different approaches for game development so I am posting this question so I can conclude which approach remains better for overall game structure.
For example, I have a 3d mobile game with 20 levels in it and levels you can put either in small or medium length section, I mean those are not too big to deal in processing.
Is it remain better to create 20 different levels prefabs in a single scene and load them when each one required? or is it better to create 20 scenes for these 20 levels of gameplay?
Prefab or scene which one creates overhead for the game engine?
If small or medium size mobile games, if we create and manage within a single scene then will it create any performance issue?
On multiple retry game (small but hard games), whether to load a game scene or load gameplay prefabs again and again? which one not create any performance issue?
Please share your opinion and knowledge regarding above my questions and I hope other members also found useful this post in future :)
Answer by Vega4Life · Aug 04, 2019 at 03:48 PM
In your example there isn't much of a difference. Loading a scene doesn't have overhead. You can test this by literally loading an empty scene. The overhead is the gameObjects in the scene that are being loaded into memory.
Another way to show this is using your example. Imagine you had 20 levels, but you bundled each level into a prefab. If you had one scene, then instantiated one of those levels via a prefab, there will be a hitch or some lag (depending on how much needs to be loaded). If instead you loaded a scene with the same level prefab, it would hitch or lag the same exact amount. There's really know difference. It comes down to what you are loading.
For me, with 20 levels, just use scenes. The only time you may have a problem (and this is a problem with prefabs too) is when you get big hitches because of how big the levels are in the scenes. There are some tricks to mitigate this issue if it does arise. And its basically separating out your scene into many prefabs. For example if you have terrain, trees, characters, etc - group all those things into prefabs. Then you load them into the scene via some manager when the scene loads, but the trick is to load one prefab per frame. This stops the game from hitching or pausing. There is a little more to it then that but its the general idea - and this is probably more of a trick for additive scenes.
Nevertheless, hope this helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220612210022im_/https://answers.unity.com/themes/thub/images/avi.jpg)