DiskSavedGameDataStorer for mobile

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
marche4ever
Posts: 20
Joined: Mon Jan 21, 2019 5:29 pm

DiskSavedGameDataStorer for mobile

Post by marche4ever »

Hello, I'm trying to find the best way to save my game's progress. I'm wondering why DiskSavedGameDataStorer does not support mobile? My game will be released for both PC and mobile platform. I'm hesitant to use PlayerPrefs because lots of web discussions say that it's bad practice. Do I have to write my own DataStorer? If so, I need to know how to get it to work for both PC and mobile. Thanks.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: DiskSavedGameDataStorer for mobile

Post by Tony Li »

Hi,

The next update will let you use DiskSavedGameDataStorer on mobile. If you want to use it right away, change line 19:

Code: Select all

#if UNITY_EDITOR || UNITY_STANDALONE
to:

Code: Select all

#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID
However, if you're making an offline mobile game, saving to PlayerPrefs is a perfectly valid place to save. Concerns online are typically about size (saved games in PlayerPrefs have a 1 MB limit on some platforms), speed (PlayerPrefsSavedGameDataStorer is optimized, so this isn't a concern), and security (PlayerPrefsSavedGameDataStorer can encrypt, so this isn't a concern either).
marche4ever
Posts: 20
Joined: Mon Jan 21, 2019 5:29 pm

Re: DiskSavedGameDataStorer for mobile

Post by marche4ever »

Hi Tony,
I'm also concerned by this quote.
It is up to you, but on android at least it is very easy to reset these things on your phone. Most of the time it is best to save things that you do not want to lose externally so that the user cannot manipulate or delete it. I am not positive how easy it is to do on iOS, but on android all you have to do is go to the app in the application manager and clear the cache and it will remove all of those PlayerPrefs.
https://gamedev.stackexchange.com/quest ... layerprefs

Are PlayerPrefs as easily to be lost through cache clearing as described in the above? If so, would DiskSave be better?

Also, When's the next update? How do I keep my version of Dialogue System updated(through play store)?

Thanks.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: DiskSavedGameDataStorer for mobile

Post by Tony Li »

Hi,

PlayerPrefs aren't cleared when you clear the cache. You only need to do a quick test to confirm. (I just did, BTW.) This manual page explains where PlayerPrefs are stored on various platforms and how they can and can't be cleared.

However, if the player uninstalls the app or goes into Settings > Apps > (your app) and selects Clear Data, they will lose their PlayerPrefs data as well as any disk-based saved games. Likewise if they lose their device. The only way to handle these cases is to store the data externally, such as on your server. And you could certainly write a saved game data storer to do that if you wanted. The nice thing about the Dialogue System's Save System is that you can use the PlayerPrefsSavedGameDataStorer while you're developing your game, and then later just swap it out with a different SavedGameDataStorer component without having to change anything else.

As far as preventing the player from manipulating data, as I mentioned before the PlayerPrefsSavedGameDataStorer and DiskSavedGameDataStorer both encrypt their data.

I just checked the version 2.1.0 DiskSavedGameDataStorer, and it does need some modifications to work on mobile. I'll try to make sure those changes are in version 2.1.1. When version 2.1.1 is available (scheduled for next week), you'll be able to import the update from the Asset Store.
hamatchi23
Posts: 5
Joined: Sun Dec 18, 2022 12:07 am

Re: DiskSavedGameDataStorer for mobile

Post by hamatchi23 »

Hello Where can I find the save file on android if I set the "store save files in : Data Path" ?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: DiskSavedGameDataStorer for mobile

Post by Tony Li »

Hi,

If you store in Data Path, it will be here:
https://docs.unity3d.com/ScriptReferenc ... aPath.html

If you store in Persistent Data Path (more common), it will be here:
https://docs.unity3d.com/ScriptReferenc ... aPath.html
hamatchi23
Posts: 5
Joined: Sun Dec 18, 2022 12:07 am

Re: DiskSavedGameDataStorer for mobile

Post by hamatchi23 »

Hmm when I get to the package folder of my game the only folder in that file location is cache and files and neither both have the save data :(

I tried to change the Data path to persistent data path
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: DiskSavedGameDataStorer for mobile

Post by Tony Li »

Temporarily tick the Debug checkboxes on the SaveSystem and DiskSavedGameDataStorer components. When you save the game on Android, examine the logs. It will indicate the path.

Note: If you're using PlayerPrefsSavedGameDataStorer, the game will be saved here.
hamatchi23
Posts: 5
Joined: Sun Dec 18, 2022 12:07 am

Re: DiskSavedGameDataStorer for mobile

Post by hamatchi23 »

Ok I'll try it thanks for helping me sir
Post Reply