Is it possible to modify this code to not use BinaryFormatter and can still Save and Load data the same way?
I want data saved in plain text.
public void Save()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.dataPath + "/playerInfo2.txt");
PlayerData pData = new PlayerData();
pData.Money = money;
pData.Levels = levelC;
bf.Serialize(file, pData);
file.Close();
}
public void Load()
{
if (File.Exists(Application.dataPath + "/playerInfo2.dat"))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.dataPath + "/playerInfo2.txt", FileMode.Open);
PlayerData dataa = (PlayerData)bf.Deserialize(file);
file.Close();
money = dataa.Money;
levelC = dataa.Levels;
}
}
[System.Serializable]
public class PlayerData
{
public int Money;
public List<bool> Levels = new List<bool>();
}