示例#1
0
 public void Save()
 {
     try
     {
         var             path       = EditorUtility.SaveFilePanel("Save Level Data", "", "savefile.bfl", "bfl");
         BinaryFormatter bf         = new BinaryFormatter();
         FileStream      file       = File.Create(path.ToString());
         tempSaveObject  saveObject = new tempSaveObject();
         saveObject.level = lvlmaker.level;
         bf.Serialize(file, saveObject);
         file.Close();
     }catch (System.Exception e)
     {
         Debug.LogError("Please choose a proper file location!");
     }
 }
示例#2
0
 public void Load()
 {
     try
     {
         var             path = EditorUtility.OpenFilePanel("Open Level Data", "", "bfl");
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(path.ToString(), FileMode.Open);
         tempSaveObject  data = (tempSaveObject)bf.Deserialize(file);
         file.Close();
         lvlmaker.level.Clear();
         lvlmaker.level = data.level;
     }catch (System.Exception e)
     {
         Debug.LogError("Invalid file selected!");
     }
 }