Пример #1
0
        public static void DeleteSave(out LevelsData data)
        {
            string path = Application.persistentDataPath + "/levels.save";

            File.Delete(path);

            CreateSave(out data);
        }
Пример #2
0
        public static void SaveData(LevelsData data)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            string     path    = Application.persistentDataPath + "/levels.save";
            FileStream _stream = new FileStream(path, FileMode.Create);

            formatter.Serialize(_stream, data);
            _stream.Close();
        }
Пример #3
0
        public static LevelsData LoadData()
        {
            string path = Application.persistentDataPath + "/levels.save";

            if (File.Exists(path))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                FileStream      _stream   = new FileStream(path, FileMode.Open);

                LevelsData data = formatter.Deserialize(_stream) as LevelsData;

                _stream.Close();

                return(data);
            }
            else
            {
                return(null);
            }
        }