Example #1
0
    void Awake()
    {
        savesFolder = Application.persistentDataPath + savesDir;
        saveInfoLoc = savesFolder + "/" + "names_of_saves.dat";

        haveOneInstance();

        if (!Directory.Exists(savesFolder))
        {
            Directory.CreateDirectory(savesFolder);
        }
        if (File.Exists(saveInfoLoc))
        {
            loadAccountInfo();
        }
        else
        {
            print("DID NOT FIND INDEX. Made a new one.");
            info = new SaveSlotFileNames();
            saveAccountInfo();
        }
    }
Example #2
0
 private void loadAccountInfo()
 {
     if (File.Exists(saveInfoLoc))
     {
         FileStream        file           = File.Open(saveInfoLoc, FileMode.Open);
         BinaryFormatter   bf             = new BinaryFormatter();
         SaveSlotFileNames listOfAccounts = (SaveSlotFileNames)bf.Deserialize(file);
         file.Close();
         info = listOfAccounts;
         foreach (string loc in info.fileNames)
         {
             if (File.Exists(loc))
             {
                 saves.Add(PlayerAccount.loadPlayerData(loc));
             }
             else
             {
                 print("Tried to load a save file that does not exist at " + loc);
             }
         }
         saveAccountInfo();
     }
 }