Page 1 of 1

FormatException: String was not recognized as a valid Boolean (solved)

Posted: Sat Sep 05, 2020 1:00 pm
by doodlinbee
Saving code :

Code: Select all

    public void SaveSequentially(int slot)
    {
        using (ES3Writer writer = ES3Writer.Create(filePath: GetSaveName(slot), settings))
        {
            writer.Write(SceneManager.GetActiveScene().name);
            writer.Write(true);
            writer.Write(false);           
        }
    }
The output :

Code: Select all

{"lighttests"truefalse
}
Loading code :

Code: Select all

    public void LoadSequentially(int slot)
    {
        using (ES3Reader reader = ES3Reader.Create(GetSaveName(slot), settings))
        {
            print(reader.Read<string>());
            print(reader.Read<bool>());
            print(reader.Read<bool>());   
        }
    }
 
When loading, the first read string is ok, but the read bool is not ok. I've got the FormatException: String was not recognized as a valid Boolean

Any ideas ?

Re: FormatException: String was not recognized as a valid Boolean

Posted: Sat Sep 05, 2020 6:30 pm
by Joel
Hi there,

You should only use classes and methods which are documented here. As ES3Writer and ES3Reader are only used internally, they will not work as you expect.

In your case you should follow the instructions here if you want to improve performance:
https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel

Re: FormatException: String was not recognized as a valid Boolean

Posted: Sat Sep 05, 2020 8:02 pm
by doodlinbee
Hi there,

I don't quite understand the cache system. How to save values in it? Like how to do the equivalent of my OP with the cache?


(I'm looking for performance improvements because i have thousands of keys to store and doing the 'Getting started' way with "ES3.Save" took several minutes to save)

Re: FormatException: String was not recognized as a valid Boolean

Posted: Sat Sep 05, 2020 8:23 pm
by Joel
Hi there,

The equivalent would be:

Code: Select all

var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save("myKey1", SceneManager.GetActiveScene().name, GetSaveName(slot), settings);
ES3.Save("myKey2", true, GetSaveName(slot), settings);
ES3.Save("myKey3", false, GetSaveName(slot), settings);
ES3.StoreCachedFile(GetSaveName(slot));
All the best,
Joel

Re: FormatException: String was not recognized as a valid Boolean

Posted: Sat Sep 05, 2020 11:03 pm
by doodlinbee
Alright thanks for the help ! :)