Hi all! I have a quick question for you. My game currently has 14 scenes, 1 menu scene and 13 levels. My goal is to have 120 - 220 levels.
Should i make every level a prefab or should i keep them as scenes? What is the performance impact of having many scenes? Will many scenes increase build time or startup time?
You can think of Prefabs as Serialized (Saved to Disk) GameObjects.
All the Prefab mechanics available in the Editor (Apply/Revert) is no longer available at runtime.
At runtime, it simply means that your objects are saved as data stored in the project instead of saved in the scene.
Although, unless you handle some scripts with very big data, what really weights are the resources (Assets) such as textures and meshes. And those will only be stored once anyway.
So, I would say you don’t want to make an individual Prefab for every scene. But you do want to make prefabs for objects or groups of objects that you use often in different levels.
If you have that many levels, it sounds like you’re creating a puzzle-type game, in which case you might want to consider placing the level objects programmatically through a script rather than saving them as separate scenes. There are many games that have only a single scene, and titles, credits, options menus, and the main game screen are simply (de)activated in that single scene as necessary. Remember that you can have multiple cameras if necessary!
Otherwise, the choice of prefab/scene is somewhat personal preference - now that async scene loading is available in Unity Personal, I’m tending to store all my level data in separate scenes because you typically get a smoother experience than instantiating a prefab.
Be aware that any prefab that is referenced in your scene ( through -for example- a level manager that references all existing levels in an array, being a scriptable object or a game object or whatever, as long as it is referenced in your scene ) WILL BE LOADED IN MEMORY, as well as ALL THE PREFABS it references and ALL THE RESOURCES that are referenced by those prefabs (recursively).
This behaviour ensure that everything a prefab is made of is immediately available at runtime, for instantiating objects from it as fast as possible.
The drawback of course is that when having such organization of levels as prefabs, directly or indirectly referenced by the scene ( ex scene → level manager game object → scriptable object level list → prefabs ), your memory is filled with all your levels and all the resources needed by those levels, while you only need one level and its resources at the same time.
You should rather use Resource loading instead, or scenes loading.