- Home /
Multiple scenes or one scene for all game levels?
Hi!
I am planning a game that will include a lot of levels that can be quite big and some quite small but I started to think about something. Would it be best suited for me to use like 30 scenes for each level of the game or use one scene and then somehow load each level into that scene? What would be the best when it comes to best performance?
Answer by incorrect · Mar 12, 2015 at 05:11 PM
That depends on type of game you are going to make.
If it's something arcade-like with lots of levels with some variations, making a single scene for gameplay and initializing it with different parameters can help you to be sure that there will be no particular levels where you've just forgotten to add some scripts or objects and their relations, which leads to accidental bugs. Obviously that way does not help when your levels have not much in common.
On the other hand, making each level to be a separate scene gives you two benefits:
You can make each level absolutely different in comparison to other ones.
Sometimes it's easier to make lots of levels manualy.
So if to compare this two methods:
Making levels as scenes is a straightforward way which takes long time to do and gives you lots of monotonous but easy work to do
Making levels as one scene and initializing it with different parameters is a more reliable way and can save you lots of time if you will find a way to generate those levels quickly, but implementing initialization system is a bit trickier in comparison to 'lots of scenes' method.
So you should consider if single-scene method will give you enough benefits, otherwise it's easier to spam those scenes for the god of scenes! :)
Thank you for this information! I will probably do the multiple scene method since the levels can be quite big and uses a lot of audio components and such.
@Real$$anonymous$$TG, but keep in $$anonymous$$d that one day you'll have to implement some automatic initialization systems. The day when you'll give up on trying to fix or adjust tons of levels. :)
@Real$$anonymous$$TG, prefabs only help to make levels to have something in common, but will do nothing to make difference. :)
According to me, choose 2nd method in which all levels contains in single scene, which is better in terms of performance. I am messing around since some days. In my game, all levels having blocks in certain pattern, so I made each level to prefab then added into 'Resources' folder. Then runtime I load levels whenever needs.
i'm still wondering how do you load to next level if you only have 1 scene, i'm still trying to figure this out
You have to come up with a system yourself to handle loading the next level. You need to come up with some way to store a description of the level and a level initializer that has a way to interpret those level descriptions and instantiate all the objects that make up the level. Essentially, making your own scene loader.
It's just more efficient because you have more control over what's being loaded and unloaded and you can implement inter-scene object pooling. If you blow away everything in a scene and need to remake it, you can't benefit from object pooling when it comes to loading a level in.. and you might get a big frame drop caused by garbage collection at some arbitrary point after loading a new scene.
It's also less bug prone as you don't need to go through every level and make sure it has all the right scripts in place, as indicated above.
Answer by SkillcraftHD · Oct 15, 2020 at 07:30 PM
@flckev You can just make a script and when loading different levels you can spawn he objects using Instantiate() to the positions you want. You can also spawn them with a specific rotation or scale if you want to. That would be like: GameObject a = Instantiate(ExamplePrefab, targetPosition, Quaternion.Euler(targetRotation)); a.localScale = targetScale;
Your answer
Follow this Question
Related Questions
LoadSceneMode.Single seems to be not working. 0 Answers
Loading Screen? 6 Answers
Allow userto load custom unity levels/scenes. 2 Answers
Classic Resident Evil-style room loading/level streaming? 4 Answers