How to view .es3 type file?

Discussion and help for Easy Save 3
Post Reply
mdeim
Posts: 27
Joined: Sat May 09, 2020 7:31 pm

How to view .es3 type file?

Post by mdeim »

Hi Joel,

I wanted to know is there a way to simply open and view the .es3 that was just saved so I can view the contents saved?
I'm thinking one way to temporarily get around this issue is to save both .es3 and also save it as a.json file but not sure ES3 will accept that when I save.

Either way, if you have any advice on this, I would appreciate it since I can't find anything on this on the forum.
Last edited by mdeim on Sun May 10, 2020 12:03 am, edited 1 time in total.
mdeim
Posts: 27
Joined: Sat May 09, 2020 7:31 pm

Re: How to view .es3 type file?

Post by mdeim »

Oh, I just changed the extension to .json and it works haha, so simple.

I would like to confirm though, when I call ES3File.Sync(), does it automatically create a new file for you if you provide the path to file even if one wasn't created yet?. Example ES3File.Sync("..../[game file name here]/[file name here]"), because I'm noticing this is happening and I want to make sure it's nothing else in my code. I don't see anything about this in the docs.

Is there a method to convert the JSON to bytes array?

Lastly, I wanted to ask you about best practice. I plan to create the save file first and then when it's time to send to storage, I will sync the cached file, turn it into bytes and save with ES3.SaveRaw, then send it to cloud. I've never done it like this before so I'm wondering if it's best practice to create it on player's system like this. I would prefer to create the bytes file from the cached es3file but there is no ES3File.SaveRaw method so...What would you suggest?

Thank you!
Last edited by mdeim on Sun May 10, 2020 12:03 am, edited 1 time in total.
User avatar
Joel
Moodkie Staff
Posts: 4848
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to view .es3 type file?

Post by Joel »

Hi there,

ES3File.Sync automatically creates the file if it doesn't exist.

You can load a JSON file as a byte array using ES3.LoadRawBytes(filePath).

Regarding your final question, I'm unsure why you want to convert the data to a byte array first? Turning it into a byte array and then saving it to file is redundant, because the byte[] representation of the data is the same as the string representation, so you would just be loading the file and then overwriting it with the exact same data.

Note that you can get the ES3File as a byte[] array using ES3File.LoadRawBytes.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
mdeim
Posts: 27
Joined: Sat May 09, 2020 7:31 pm

Re: How to view .es3 type file?

Post by mdeim »

Thank you Joel,

That was very helpful and it worked easily.

For your question, I would have a JSON file first, but only the bytes array would be sent to the cloud.
I would have it for two reasons. First, it's useful to see what I'm saving while developing the game.
Second, once ready for production i would rather not save the JSON anymore but instead, I would prefer to have the ability to make everything a byte with something like...

Code: Select all

ES3File.SaveAsByte(<Vector3>("SomePosition", TheVector3PositionVar)
...but there isn't a method for that in the API which can save a byte to a cached file, as far as I know so this why I have it set up like this.

This is what I have now:

Code: Select all


        if (ES3.FileExists(SaveFilePathToFile)) {
            byte[] BytesFile = ES3.LoadRawBytes(GetSaveFilePathToFile());
            ES3.SaveRaw(BytesFile, GetSaveFilePathToFileBytes());
        }

After this I would have a .txt file(created in another method) and .bytes file in my saves directory.
After data is sent, I plan on removing the .json and .bytes file and then do a GET request for the saved bytes file back from the cloud. I guess this part is redundant, but it also makes sure the correct data was saved and sent.

Lastly, I have a question. If I just do...

Code: Select all

 ES3.Load<Vector3>("myPosition", Vector3.zero); 
...even though I'm receiving only bytes, not JSON anymore, would it work out of the box or would I need to code a step in between where I convert byte back to JSON?

Thank you for all your help!
User avatar
Joel
Moodkie Staff
Posts: 4848
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to view .es3 type file?

Post by Joel »

Hi there,

Are you trying to convert it to bytes so that it's not readable? If you load a JSON file as a byte[] array and then save that byte[] array as a file (as you're showing in your example), the new file will be exactly the same as the old file. If you want to obfuscate the file, you should use encryption.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
mdeim
Posts: 27
Joined: Sat May 09, 2020 7:31 pm

Re: How to view .es3 type file?

Post by mdeim »

Oh, I just though some cloud platforms only accept data as bytes. I know about encryption, I was going to encrypt it as well actually, but it(byte/json) all depends what the cloud platform accepts.

Would you mind to answer the question I had in the end, please?

Basically, if the data came back as bytes would

Code: Select all

ES3.Load<Vector3>("myPosition", Vector3.zero); 
load the data back into unity the same way as if it were a JSON? Since you're saying it's basically the same thing, I guess yes right? Thank you.
User avatar
Joel
Moodkie Staff
Posts: 4848
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to view .es3 type file?

Post by Joel »

Hi there,

The data would load back into Unity in the same way.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
mdeim
Posts: 27
Joined: Sat May 09, 2020 7:31 pm

Re: How to view .es3 type file?

Post by mdeim »

Thank you for your help Joel :D

I just posted a review.
User avatar
Joel
Moodkie Staff
Posts: 4848
Joined: Wed Nov 07, 2012 10:32 pm

Re: How to view .es3 type file?

Post by Joel »

Thank you, really appreciate your feedback :)

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