Page 1 of 1

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

Posted: Mon Nov 04, 2019 4:30 am
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");
}

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

Posted: Mon Nov 04, 2019 8:09 am
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

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

Posted: Mon Nov 04, 2019 2:18 pm
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.

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

Posted: Mon Nov 04, 2019 2:27 pm
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

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

Posted: Mon Nov 04, 2019 3:42 pm
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. ;) ;) ;)

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

Posted: Fri Apr 10, 2020 8:37 am
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.

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

Posted: Fri Apr 10, 2020 8:46 am
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

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

Posted: Mon May 11, 2020 7:18 am
by jwiden
Joel wrote:
Joel
Hi Joel,
How to save a file in run time. i created it in resource folder?
Thanks.

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

Posted: Mon May 11, 2020 7:25 am
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