It’s me again with another horror story revolving the wonderful WebGL technology that’s making me hate everything.
I am updating my game to WebGL and cannot change how I am serializing data or thousands of players will have their data wiped at this point it isn’t worth updating my game at all as I’d rather not update than erase everyone’s data it’ll be less damaging to my company’s reputation.
Everyone says updating to WebGL is ‘easy’ well it’s not. Seems to be a lot of stuff I was doing with the web player that’s no bueno for WebGL.
I am using a very basic binary formatter + memory stream + player prefs and writing to hard drive which worked in the old Unity Player, it works in Firefox with WebGL but Chrome is, once again, being that special snowflake where it won’t work.
It isn’t serializing data and it isn’t deserializing data either. So basically my entire saving and loading process is void in Chrome. This is the gist of my saving code. Do I need to do anything differently in Chrome? Add any Javascript? Every time I think I’m done updating new problem shows up. I was Googling for some solutions but to no avail as people’s suggestions would alter how I’m saving data ultimately leading to all player data going bye bye.
Basic basic
BinaryFormatter bf = new BinaryFormatter();
MemoryStream memoryStream = new MemoryStream();
bf.Serialize(memoryStream, savedData);
bf.Serialize(memoryStream, savedData2);
tmp = System.Convert.ToBase64String(memoryStream.ToArray());
PlayerPrefs.SetString("savedData", tmp);
PlayerPrefs.Save();
Is it going to be possible to make this work without my Chrome players losing their data?
I wish I knew more than C#. All this web development, security issues and compatibility problems are driving me insane.
How much data are you saving?
Are you sure PlayerPrefs are not saved at all? Saving is an asynchronous operation and perhaps it takes longer on Chrome compared to Firefox.