Пример #1
0
        public static void SaveGame(int slotNum)
        {
            BinaryFormatter bf           = new BinaryFormatter();
            string          mySlotString = Application.persistentDataPath + "/gameData" + slotNum.ToString() + ".dat";
            FileStream      file         = File.Create(mySlotString);
            var             json         = SimpleEncryptDecrypt.EncryptDecrypt(JsonUtility.ToJson(gameData_SO));

            bf.Serialize(file, json);
            file.Close();
        }
Пример #2
0
        public static void LoadGame(int slotNum)
        {
            string mySlotString = Application.persistentDataPath + "/gameData" + slotNum.ToString() + ".dat";

            if (File.Exists(mySlotString))
            {
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Open(mySlotString, FileMode.Open);
                JsonUtility.FromJsonOverwrite(SimpleEncryptDecrypt.EncryptDecrypt((string)bf.Deserialize(file)), gameData_SO);
                file.Close();
            }
            gameData_SO.saveSlotNum = slotNum;
        }