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.
☝ 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:
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.