I am making a towers defence game, and I need to know how I can load levels that have much the same data. For example, every level will need a game manager, tower placement script, etc.
I have tried storing level-specific stuff (geometry, paths) as a prefab, and then loading that prefab into a pre-made scene when the game starts, and this works okay. The level is loaded and everything works fine, except for one thing. Lighting data isn’t saved with the prefab. Everything in a level prefab is static, so the level ends up looking quite different in editor because unity has calculated lighting data, but when instantiated from a prefab none of the lighting data is present.
It is actually possible (though not very intuitive) to calculate and use lightmaps for prefabs.
Basically, you have to take your prefab, place it in an empty scene with lights, and calculate the lightmap for it. Then, you need to copy the near and far lightmaps that you have generated somewhere else (otherwise they will be overwritten when you try to calculate the next lightmap).
Then, when you load your scene, you will need to manually apply the lightmap you have calculated to your prefab. You can do that by setting the lightmapIndex for the prefab’s MeshRenderer:
This index refers to a list of available lightmaps that is stored in the LightmapSettings static class. You will also need to build this list manually. It has a lightmaps property that contains a LightmapData array. If you have two prefabs that you want to lightmap, for example, then you will need to build your list with those two, and assign the right index to them.
You can define a simple c# class that describes your level content, serialize/desirialize it to JSON file format with Newtonsoft.json.JsonConvert and use File.ReadAllText to load/save it to disk
Somewhere in your code have a method that loads up an instance of your level Describer class and Instantiates all the GameObjects accordingly.
This requires quite a bit of engineering work, but will teach you a lot if you want to spend the time on it.
I would start by reading about JSON, serialization, NuGet and Newtonsoft.json
It will probably take a few days of work for an absolute beginner.