too many overloads on ES.Load()?
Posted: Thu Jun 25, 2020 4:04 am
I followed the getting started and want to do something like:
ES3.Load<string>("playerName", "Default Name")
but I noticed if I call that first without saving then as expected the save file isn't found but it throws an exception instead of giving me the default value.
Debugging why, it turns out its not going to this overload like I expected:
public static T Load<T>(string key, T defaultValue)
but instead its going to:
public static T Load<T>(string key, string filePath)
So to fix that I did:
ES3.Load<string>("playerName", "Default Name", ES3Settings.defaultSettings);
hoping that it would go to:
public static T Load<T>(string key, T defaultValue, ES3Settings settings)
but instead it went to:
public static T Load<T>(string key, string filePath, T defaultValue)
So to fix that I did:
ES3.Load<string>("playerName", "ES3/ES3Defaults", "Default Name", ES3Settings.defaultSettings);
and that finally worked cause it went to:
public static T Load<T>(string key, string filePath, T defaultValue, ES3Settings settings)
but geez. There's no exposed way to get to
private const string defaultSettingsPath = "ES3/ES3Defaults";
so I have to mirror that.
Seems like there's a few too many overloads named Load() when I just want to do something basic like this.
Is there a better way?
Thanks!
ES3.Load<string>("playerName", "Default Name")
but I noticed if I call that first without saving then as expected the save file isn't found but it throws an exception instead of giving me the default value.
Debugging why, it turns out its not going to this overload like I expected:
public static T Load<T>(string key, T defaultValue)
but instead its going to:
public static T Load<T>(string key, string filePath)
So to fix that I did:
ES3.Load<string>("playerName", "Default Name", ES3Settings.defaultSettings);
hoping that it would go to:
public static T Load<T>(string key, T defaultValue, ES3Settings settings)
but instead it went to:
public static T Load<T>(string key, string filePath, T defaultValue)
So to fix that I did:
ES3.Load<string>("playerName", "ES3/ES3Defaults", "Default Name", ES3Settings.defaultSettings);
and that finally worked cause it went to:
public static T Load<T>(string key, string filePath, T defaultValue, ES3Settings settings)
but geez. There's no exposed way to get to
private const string defaultSettingsPath = "ES3/ES3Defaults";
so I have to mirror that.
Seems like there's a few too many overloads named Load() when I just want to do something basic like this.
Is there a better way?
Thanks!