コード例 #1
0
    public static void loadGame()
    {
        //Debug.Log("You got to loadGame()!");
        wasCalled = true;
        Object o = new Object();

        if (File.Exists(Application.persistentDataPath + "/strategygame.save"))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream      fs = File.Open(Application.persistentDataPath + "/strategygame.save", FileMode.Open);
            amd = (AllMyData)bf.Deserialize(fs);
            SceneManager.LoadScene(amd.currentLevel, LoadSceneMode.Single);
            //Application.LoadLevel("Main");
            //Debug.Log("The current build index is " + amd.currentLevel);
        }
    }
コード例 #2
0
 public static void saveGame()
 {
     Debug.Log(Application.persistentDataPath);
     if (File.Exists(Application.persistentDataPath + "/strategygame.save"))
     {
         BinaryFormatter bf  = new BinaryFormatter();
         AllMyData       amd = new AllMyData();
         File.Delete(Application.persistentDataPath + "/strategygame.save");
         FileStream fs = File.Create(Application.persistentDataPath + "/strategygame.save");
         bf.Serialize(fs, amd);
         fs.Close();
     }
     else
     {
         BinaryFormatter bf  = new BinaryFormatter();
         AllMyData       amd = new AllMyData();
         FileStream      fs  = File.Create(Application.persistentDataPath + "/strategygame.save");
         bf.Serialize(fs, amd);
         fs.Close();
     }
 }