basic easy save 3

Discussion and help for Easy Save 3
Post Reply
june
Posts: 2
Joined: Fri Jul 23, 2021 3:23 am

basic easy save 3

Post by june »

Hi,

When I follow the getting started tutorial and use

ES3.Save("myInt", 123);
myInt = ES3.Load("myInt", defaultValue); <---- this doesn't work

It seems like I need to use

myInt = ES3.Load("myInt", filepath, defaultValue); <------ (question 1)Is there a way to ignore filepath like the manual?

and also the filepath should always contain ".es3" as in "myFile.es3"(question2)?
(question 3) can I load a csv spreadsheet from resources?
since I need to use "var myValue = ES3.Load<Vector3>("myKey", "myFile.bytes", settings);" how would I load filename.csv?

Thank you very much in advance!
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: basic easy save 3

Post by Joel »

Hi there,

I don't appear to be having any issues with the defaultValue parameter, and have had no reports of this. I used the following script to test this and it outputs 345 as expected:

Code: Select all

using UnityEngine;

public class SaveInt : MonoBehaviour
{
    void Start()
    {
        ES3.DeleteFile();
        Debug.Log(ES3.Load("myInt", 345)); // Returns 345
    }
}
Please could you create a script which I can drop into a new scene in a new project which replicates this? Also please ensure you are using the latest version of Easy Save.

Also you can use any file extension that you want. The only exception is when loading from Resources, where you must use the extension ".bytes".

CSV is a file format, not a file extension. So it doesn't matter if the file extension isn't ".csv" as long as the data inside that file is still in CSV format.

Regarding loading a CSV file from Resources, the instructions in the Loading from Resources guide also apply when using ES3Spreadsheet (see the ES3Spreadsheet guide).

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
june
Posts: 2
Joined: Fri Jul 23, 2021 3:23 am

Re: basic easy save 3

Post by june »

Hi Joel,

Thank you very much for your reply.
As you told me the code works really well. (not sure why it didn't work before)

I also was curious if I can load a text file like filename.txt as a whole from resources.
I want to drag and drop a filename.txt file in resources and load it.

var myValue = ES3.Load<Vector3>("myKey", "myFile.bytes", settings); <----- since I want to load the whole file there is no "myKey"
and also since I drag and dropped a .txt file, the file would end in ".txt" rather than "bytes".
Would this still work or be possible?

Thanks again.

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

Re: basic easy save 3

Post by Joel »

Hi there,

To do this you can use Unity's Resources functionality. I.e. to load a file named MyFile.txt:

Code: Select all

TextAsset textFile = Resources.Load<TextAsset>("MyFile"); // No extension required
For info on the TextAsset object that it returns, please see Unity's docs:
https://docs.unity3d.com/ScriptReference/TextAsset.html

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply