/// <summary> /// Load saved values from preferences or set to default if not found. /// </summary> /// <param name="prefix"></param> /// <param name="useSecurePrefs"></param> public void Load(string prefix = "", bool?useSecurePrefs = null) { foreach (var variable in BoolVariables) { if (variable.PersistChanges) { variable.Value = PreferencesFactory.GetBool(prefix + variable.Tag, variable.DefaultValue, useSecurePrefs); } else { variable.Value = variable.DefaultValue; } } foreach (var variable in FloatVariables) { if (variable.PersistChanges) { variable.Value = PreferencesFactory.GetFloat(prefix + variable.Tag, variable.DefaultValue, useSecurePrefs); } else { variable.Value = variable.DefaultValue; } } foreach (var variable in IntVariables) { if (variable.PersistChanges) { variable.Value = PreferencesFactory.GetInt(prefix + variable.Tag, variable.DefaultValue, useSecurePrefs); } else { variable.Value = variable.DefaultValue; } } foreach (var variable in StringVariables) { if (variable.PersistChanges) { variable.Value = PreferencesFactory.GetString(prefix + variable.Tag, variable.DefaultValue, useSecurePrefs); } else { variable.Value = variable.DefaultValue; } } foreach (var variable in Vector2Variables) { if (variable.PersistChanges) { variable.Value = PreferencesFactory.GetVector2(prefix + variable.Tag, variable.DefaultValue, useSecurePrefs) ?? Vector2.zero; } else { variable.Value = variable.DefaultValue; } } foreach (var variable in Vector3Variables) { if (variable.PersistChanges) { variable.Value = PreferencesFactory.GetVector3(prefix + variable.Tag, variable.DefaultValue, useSecurePrefs) ?? Vector3.zero; } else { variable.Value = variable.DefaultValue; } } }