I have a serlialisable class that I use to persist my data between sessions which works fine on mobile / desktop but does not work when exported to WebGL (Unity 2017)
[Serializable]
public class GameData
{
public float CoinBalance = 0;
public List<int> ItemCounts = new List<int>();
public List<bool> ItemUnlocks = new List<bool>();
public List<int> Upgrades = new List<int>();
public List<int> UpgradeStates = new List<int>();
public List<int> ModStates = new List<int>();
public List<float> PowerupTimers = new List<float>();
public List<bool> AchievementUnlocks = new List<bool>();
}
public void SaveGame()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/gamedata.bin", FileMode.OpenOrCreate);
bf.Serialize(file, GameData);
file.Close();
}
void LoadGame()
{
if (File.Exists(Application.persistentDataPath + "/gamedata.bin"))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/gamedata.bin", FileMode.Open);
_GameData = bf.Deserialize(file) as GameData;
file.Close();
}
}
Its all pretty bog standard, but just does not work, no errors or exceptions, just doesn’t work.
I have another game exported from Unity 5.4 with similar data that works just fine when exported to WebGL. Has something broken in Unity 2017?