I built an in-game level editor for my staff to use and right now the level data is saved via this method:
public static void SaveLevel(Level level, int levelName) {
if (!Directory.Exists(SavePath))
{
Directory.CreateDirectory(SavePath);
}
using (var stream = new FileStream($"{SavePath}/Levels/{levelName}", FileMode.Create))
{
Formatter.Serialize(stream, level);
}
}
Now… in the editor I can obviously just load it like so:
public static Level GetLevel(int level) {
var path = $"{SavePath}/Levels/{level}";
if (File.Exists(path)) {
using (var stream = new FileStream(path, FileMode.Open)) {
return (Level) Formatter.Deserialize(stream);
}
}
return null;
}
Now when building these files are obviously not going to be there. I could place them in resources, but I have no idea how to take the object returned from Resources.Load and get my data from it.