Predfined Level Generation Procedural vs Scene

I am designing a puzzle game that has predefined levels and I can’t determine what the best approach for level building is.

I am using a 2D coordinate system to place objects. Each object will start at a predefined position and be able to move around the board at the user’s discretion. I have a build where I created each level individually and saved them as their own scene, I can then load them as needed through a level selection screen… However, I find this to be flawed for 2 reasons:

  1. I plan to expand this idea to allow a “Time Attack” mode where the user will be forced to complete an X number of levels under a time limit and require a seamless level load.

  2. Build size is way larger.

This has lead me to still predefine my levels, but rather generate them procedurally. I do this by passing in the level number to a switch and loading each asset at the appropriate coordinates.

Is there a better way to do this? Pros/Cons of my current options?

First off, let’s look at a few of your options of how to approach loading levels.

  1. Multiple scenes, the way you’re currently handling it: This allows you to have discrete, large-scale environments separated from each other with a relatively easy means of loading and unloading data between uses.

  2. Prefabs: Rather than loading separate scenes, remove the existing “level” prefab and replace it with the next one. Unlike using multiple scenes, however, you will likely need to manually assign the “levels” to an array or List.

  3. Procedural assembly: Less likely what you’re looking for in this case, but still a potential option for level construction. While this can be implemented with difficulty level determined as part of the level generation algorithm, this would certainly be the most difficult to implement, but potentially the most expansive, as it could potentially provide an infinite number of levels.

Now, between these three concepts, I believe what you’re looking for would be option 2.

You would probably be able to load up each scene, create an empty game object at (or for 2D?) and make your level a child of that. Then, that would be your prefab to create for each level.

Rather than loading a scene, Destroy() your current “level” prefab and replace it with the next one in line, based on an array of GameObjects (your level prefabs) rather than Applcation.LoadLevel().