public static void SaveAmmo(PizzaBoyController player) { //makes file binary BinaryFormatter formatter = new BinaryFormatter(); //stores file to a consistent location string path = Application.persistentDataPath + "/ammo.txt"; FileStream stream = new FileStream(path, FileMode.Create); //collects data PlayerData data = new PlayerData(player); //writes data to file formatter.Serialize(stream, data); stream.Close(); Debug.LogError("Saved ammo"); }
public PlayerData(PizzaBoyController player) { lives = player.lives; ammo = player.ammo; }