Error when viewing save data in File Editor

Discussion of problems, ideas, suggestions and more.

Error when viewing save data in File Editor

Postby jrhee » Sat May 16, 2015 2:18 am

Hello,

Starting playing with ES2, looks great so far!

Ran into a problem with this test script:

public void Save()
{
using(ES2Writer writer = ES2Writer.Create("testSave.txt"))
{
writer.Write("AAA");
writer.Save();
}
}
public void Load()
{
using(ES2Reader reader = ES2Reader.Create("testSave.txt"))
{
Debug.Log (reader.Read<string>());
}
}


After saving, when I try to view the file contents under Assets > ES2 > File Editor, I'm getting the error:
Could not open file
This file does not contain data which is readable by Easy Save
Please make sure this file was created using Easy Save 2

The test string appears correctly in my console when I try to load. I'm on Win8, Unity 4.6.4 and ES 2.6.3.

Thanks!
jrhee
 
Posts: 3
Joined: Sat May 16, 2015 2:01 am

Re: Error when viewing save data in File Editor

Postby Joel » Sat May 16, 2015 7:39 am

Hi there,

The File Editor can't read sequentially written data because the file contains no information on what data is actually inside the file. It can only read tagged data, so for your example to be readable in the File Editor you would need to do this instead:

public void Save()
{
using(ES2Writer writer = ES2Writer.Create("testSave.txt"))
{
writer.Write("AAA", "myTag");
writer.Save();
}
}
public void Load()
{
using(ES2Reader reader = ES2Reader.Create("testSave.txt"))
{
Debug.Log (reader.Read<string>("myTag"));
}
}


I've added a note to the docs page to clarify this.

All the best,
Joel
User avatar
Joel
Moodkie Staff
 
Posts: 1640
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error when viewing save data in File Editor

Postby jrhee » Sat May 16, 2015 4:51 pm

Ah thanks, makes sense- thanks for the quick reply.

Noticing a related issue now where after the first save (where the save file is created), when I try to save again I get the following exception:

ES2InvalidDataException: Easy Save 2 Error: The file provided does not contain data that is readable by Easy Save. Please make sure that file was created by Easy Save.
ES2Reader.Next ()
ES2Reader.DeleteTags (ICollection`1 tags, .ES2Writer writer)
ES2Writer.Delete ()
ES2Writer.Save (Boolean checkForOverwrite)
ES2Writer.Save ()
GameMgr.Save () (at Assets/Scripts/GameMgr.cs:77)
GameMgr.Update () (at Assets/Scripts/GameMgr.cs:49)

Thanks,
John
jrhee
 
Posts: 3
Joined: Sat May 16, 2015 2:01 am

Re: Error when viewing save data in File Editor

Postby Joel » Sat May 16, 2015 6:25 pm

Ahh, I think I can see what's causing this in your code.

When writing sequentially, you need to call writer.Save(false) rather than writer.Save().

All the best,
Joel
User avatar
Joel
Moodkie Staff
 
Posts: 1640
Joined: Wed Nov 07, 2012 10:32 pm

Re: Error when viewing save data in File Editor

Postby jrhee » Sat May 16, 2015 6:27 pm

Perfect, that did the trick- thanks again!
jrhee
 
Posts: 3
Joined: Sat May 16, 2015 2:01 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 11 guests

cron