Page 1 of 1

Global ES2Settings

Posted: Mon Jun 23, 2014 10:55 am
by Izitmee
Hi again Joel,

I was wondering if there is a way to set global ES2Settings, so that Easy Save uses those settings by default, and one can call all methods without having to pass an ES2Settings object each time. If it doesn't exist, it would indeed be pretty handy if it could be implemented?

Thanks & cheers,

Re: Global ES2Settings

Posted: Mon Jun 23, 2014 11:11 am
by Joel
Hi Daniele,

If you go to Assets->Easy Save 2 menu there's the option to "Add Default Settings Object to Scene". This allows you to set the default Data paths, Encryption and Web settings.

However, I'm guessing that you'll be wanting to set the default save location? If so, I can add support for this in the next update for you without much difficulty.

All the best,

Re: Global ES2Settings

Posted: Mon Jun 23, 2014 11:45 am
by Izitmee
That would be great, and yes, I'm talking about default save location (and also encryption). Being able to do it via code instead than by adding an object to the scene would be the best thing, imho. Personally, I setup Easy Save in my "core brain", so that everything works as expected from whatever scene I start (in case I'm testing in the editor and don't want to startup from the first one), and I suppose a lot of people tend to keep things dynamic like that.

Re: Global ES2Settings

Posted: Mon Jun 23, 2014 11:48 am
by Izitmee
P.S. thought I'd add a possible API example.

What I mean is being able to do this via code:

Code: Select all

ES2.defaultSettings = new ES2Settings {
    saveLocation = ES2Settings.SaveLocation.PlayerPrefs,
    encrypt = true,
    encryptionPassword = "somePassword"
And then Easy Save would use those settings every time one uses Load/Save/Exists/Delete

Re: Global ES2Settings

Posted: Mon Jun 23, 2014 12:06 pm
by Joel
Actually you can already do this, though it's not documented, using the static variables in ES2GlobalSettings. For example, to change the default SaveLocation, you could do:
ES2GlobalSettings.defaultSaveLocation = ES2Settings.SaveLocation.File;
Here's a list of the static variables in ES2GlobalSettings which you can use to change the defaults:
public static ES2Settings.SaveLocation _defaultSaveLocation = ES2Settings.SaveLocation.File;
public static string defaultPCDataPath = "";
public static string defaultMacDataPath = "";
public static bool defaultEncrypt = false;
public static string defaultEncryptionPassword = "pass";
public static string defaultWebUsername = "ES2";
public static string defaultWebPassword = "pass";
public static string defaultWebFilename = "file.es2";
We'll see about adding a documented version of this at some point.

- Joel

Re: Global ES2Settings

Posted: Mon Jun 23, 2014 1:23 pm
by Izitmee
This is fantastic, and all I wanted to do. Thanks Joel :)


Posted: Mon Jun 23, 2014 4:24 pm
by Izitmee
Hi Joel, and sorry for being such a bother in these days.

I am now encountering a bug, on Unity 4.5 and Easy Save 2's latest Asset Store version.

Code: Select all

StackOverflowException: The requested operation caused a stack overflow.
ES2Writer.WriteEncrypted[Boolean] (Boolean param, .ES2Type type)
I whipped out a sample package with a scene and a script that replicate the issue (doesn't contain Easy Save). The error happens as soon as I try to save, even a simple bool, if I'm using encryption. I've just imported Easy Save, created the script, and the build is set for Windows (plain Windows, not Metro nor Phone), so encryption should work.

Re: StackOverflowException

Posted: Mon Jun 23, 2014 6:09 pm
by Joel
I guess that's why we didn't document ES2GlobalSettings :)

Easy Save currently works on the assumption that encryption will always be disabled by default. By changing this, the writer responsible for encrypting tries to recursively encrypt itself, leading to a stack overflow.

We can very easily fix this with two short lines of code at our end. I'll get this included in v2.48 which we'll hopefully be submitting for approval on Friday.

If you need it earlier, contact us with your invoice number and purchase date (found in the PDF that Unity sent you when you purchased Easy Save) and I'll get a package made up for you.


Re: Global ES2Settings

Posted: Mon Jun 23, 2014 6:17 pm
by Joel
I've just merged this with the Global ES2Settings topic as it directly relates to that.
- Joel

Re: Global ES2Settings

Posted: Mon Jun 23, 2014 6:52 pm
by Izitmee
Oops didn't realize it was because of the global settings. I just contacted you as you said, and thanks again :)