Hi SteBee, I ran into this problem as well, however I believe there is an easier solution:
https://itch.io/t/140214/persistent-data-in-updatable-webgl-games
I'm no web developer, but it seems like we can write to any folder inside the browser's "idbfs" directory. I did something like this:
private string GetSavePath(string filename) { var path = Application.persistentDataPath; #if UNITY_WEBGL && !UNITY_EDITOR path = "/idbfs/YourGameNameOrAnythingHere"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); Debug.Log("Creating save directory: " + path); } #endif var result = Path.Combine(path, filename); Debug.Log("Save path: " + result); return result; }
Then you can use C#'s easy to use FileStream, BinaryFormatter, File.Open(...) etc APIs to serialize class data as usual.
I've confirmed this works with my little (soon to be released) Unity (2021.3) WebGL game that new builds correctly persist data as expected.
Verified in Chrome and Edge on Windows and Safari on macOS and iOS.
Hope this helps!