How To Make Your Save Persistent Through Different Builds At itch.io (Unity's WebGL)
Save Persistent Path Problem
It is taught that Unity’s “Application.persistentDataPath” will persist through different builds. That’s the case for desktop builds. However, if you’re uploading your builds to itch.io (or maybe some other platforms too), the URL that host the build will change every time you upload a new build. Hence, “Application.persistentDataPath” will change every time the game is updated. And the old save will be gone.
Solution To Save Persistent Path Problem
To solve that, use an absolute path for all your builds. Replace “Application.persistentDataPath” with “idbfs/YOUR_GAME_RANDOM_CODE”. I’d add some random codes like “sgwhf94hgfw” at the end just in case someone else is making a game with the same name and using the same method for saving.
PersistentDataPath returns different paths for different builds <-I actually found the answer here first, then added my own solutions to it when more problems popped up.
Create The Path
As you’re using your own defined path, Unity won’t create the path for you, so you’ll have to generate the path yourself. Just put this before you use the path:
if (!Directory.Exists(savePathName))
{
Directory.CreateDirectory(savePathName);
}
Additional Note Of WebGL save
The save file is saved in the player’s browser. So,
- The save will be gone if the player clears the browser’s data.
- If the player switch browser or computer, the old save will not be there.
Related To Saving:
Brackeys’s SAVE & LOAD SYSTEM in Unity
originally from my blog:
Files
Psycho Bathroom(Prototype)
Slash, dodge, upgrade! You're a nimble toothbrush. Protecting your master is your one job.
Status | Prototype |
Author | DDmeow |
Genre | Action, Educational |
Tags | Beat 'em up, Boss battle, Funny, Hack and Slash, upgrades |
Languages | English, Chinese (Traditional) |
Accessibility | Color-blind friendly, Subtitles |
More posts
- Added mouse support for gameplay!Jul 31, 2021
- Secret companions + (DevLog #5)Jun 29, 2021
- Improved Game Feel (DevLog #4)May 11, 2021
- More skills available!Apr 29, 2021
- Psycho Bathroom updateApr 11, 2021
Leave a comment
Log in with itch.io to leave a comment.