ES3File: Couldn't find the file on Android device.

Discussion and help for Easy Save 3
Post Reply
jwiden
Posts: 5
Joined: Mon Nov 04, 2019 4:23 am

ES3File: Couldn't find the file on Android device.

Post by jwiden »

I cannot find my file saved in the Asset from an Android device. It works well in the editor.

My code:
var path = Application.streamingAssetsPath + "/FilePos";
filePos = new ES3File(path);
if (!filePos.KeyExists(_KeyDataGame.keySaveFilePos))
{
print("coultn't find the file");
}

User avatar
Joel
Moodkie Staff
Posts: 2796
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES3File: Couldn't find the file on Android device.

Post by Joel »

Hi there,

Steaming Assets Path is not writable at runtime on Android (see https://docs.unity3d.com/Manual/StreamingAssets.html).

You should use Application.persistentDataPath instead, which Easy Save uses by default if you only specify a filename or relative path.

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

jwiden
Posts: 5
Joined: Mon Nov 04, 2019 4:23 am

Re: ES3File: Couldn't find the file on Android device.

Post by jwiden »

Joel wrote:Hi there,

Steaming Assets Path is not writable at runtime on Android (see https://docs.unity3d.com/Manual/StreamingAssets.html).

You should use Application.persistentDataPath instead, which Easy Save uses by default if you only specify a filename or relative path.

All the best,
Joel
I have a file to save the location of a gameObject created from the editor. How to load on Android?
I used the paths is Application.StreamingAssets, Application.persistentDataPath and Application.dataPath.

User avatar
Joel
Moodkie Staff
Posts: 2796
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES3File: Couldn't find the file on Android device.

Post by Joel »

Hi there,

If you want to include a file in the built player, you should use a Resources folder:
https://docs.moodkie.com/easy-save-3/es ... resources/

All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

jwiden
Posts: 5
Joined: Mon Nov 04, 2019 4:23 am

Re: ES3File: Couldn't find the file on Android device.

Post by jwiden »

Joel wrote:Hi there,

If you want to include a file in the built player, you should use a Resources folder:
https://docs.moodkie.com/easy-save-3/es ... resources/

All the best,
Joel
It works, thank you very much. ;) ;) ;)

jwiden
Posts: 5
Joined: Mon Nov 04, 2019 4:23 am

Re: ES3File: Couldn't find the file on Android device.

Post by jwiden »

Joel wrote:Hi there,
All the best,
Joel
Hi Joel,

Now, I want to load a file from is SerializeField in the inspector. How does it?
Loading a file from a resource path seems to take quite a while.
I think it would be faster to load it from an inspector or scriptableobject.

Thanks for considering my request.

User avatar
Joel
Moodkie Staff
Posts: 2796
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES3File: Couldn't find the file on Android device.

Post by Joel »

Hi there,

You can use ES3File.LoadRawString to get an ES3File as a string, and the ES3File Constructor which accepts a byte array to load the data. I.e.
var es3file = new ES3File(System.Text.Encoding.UTF8.GetBytes( yourFileAsAString ));
All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

jwiden
Posts: 5
Joined: Mon Nov 04, 2019 4:23 am

Re: ES3File: Couldn't find the file on Android device.

Post by jwiden »

Joel wrote:
Joel
Hi Joel,
How to save a file in run time. i created it in resource folder?
Thanks.

User avatar
Joel
Moodkie Staff
Posts: 2796
Joined: Wed Nov 07, 2012 10:32 pm

Re: ES3File: Couldn't find the file on Android device.

Post by Joel »

jwiden wrote:
Joel wrote:
Joel
Hi Joel,
How to save a file in run time. i created it in resource folder?
Thanks.
Hi there,

It's not possible to save to the Resources file at runtime because Unity compiles it into the executable.

If you wanted to copy the data from the file in Resources to a file on the users device, you could do the following:
var resourcesSettings = new ES3Settings();
settings.saveLocation = ES3.Location.Resources;
ES3.SaveRaw("MyFile.bytes", ES3.LoadRaw("MyFile.bytes", resourcesSettings));
All the best,
Joel
Joel @ Moodkie Interactive
Twitter - Unity

Post Reply