Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(+1)

Are you using persistent rather than session cookies to handle save data?

I started off using PlayerPrefs to save data, it was inconsistent.

I am currently using Application.persistentDataPath to create text files that store the data, along with JS_FileSystem_Sync(); , which is still inconsistent.

I'm not sure if either of these systems use cookies, I honestly don't know much about how they work. Could you point me to an article or video that might enlighten me?

(+1)

So this isn't my area of expertise, but I believe Application.persistentDataPath only persists for the lifetime of a browser instance for Web GL applications based on: https://www.reddit.com/r/Unity3D/comments/5nnj2z/webgl_saving_text_file_locally_... .  This is similar to how a session cookie-- that is, a cookie with no expiration date-- works.

Regarding tutorials: https://www.w3schools.com/js/js_cookies.asp looks pretty good, but basically you set cookies with assignments to document.cookie using javascript and read them back by setting a string to document.cookie and then scanning through it for your specific name.  There are other ways, and maybe there's something else that's the best practice for WebGL-- I'm not a WebGL programmer.  But if you *do* use cookies the thing I was trying to say was that if you don't explicitly set an expiration date (conventionally 1 full year past current time) the cookie is deleted when the browser instance ends, which can be counter-intuitive.

I will look closer into this, thank you for the resources! I would love for this to be easier, it's wild to me there's not a simple solution for this. Gotta figure out how to get c# to talk to JS to talk to the browser. It's a bit daunting, and totally new territory for me, so no promises, but I'm going to do my best to figure this out. I appreciate you!

Found a resource you might be interested in: https://3p0ch.newgrounds.com/news/post/1086279

(3 edits) (+1)

Testing this out today, thank you!

Edit: Got it working between versions. Still too early to tell if it will save between sessions, as I don't know exactly how long session cookies last by default. Testing it out on a test page so as to not screw with anything until I'm confident it is working fine

Edit2: Tested it out over a couple days, seems stable, seems to be working. The newest build has this system in place. Anyone reading this, please let me know if your data isn't saving between sessions