public static string GetString(string key, string defaultValue = "") { if (!PlayerPrefs.HasKey(key)) { return(defaultValue); } string result = SecuritySystem.Decrypt(KEY, PlayerPrefs.GetString(key)); return(result); }
public static int GetInt(string key, int defaultValue = 0) { string value = SecuritySystem.Decrypt(KEY, PlayerPrefs.GetString(key)); int result; if (int.TryParse(value, out result)) { return(result); } return(defaultValue); }
public static float GetFloat(string key, float defaultValue = 0.0f) { string value = SecuritySystem.Decrypt(KEY, PlayerPrefs.GetString(key)); float result; if (float.TryParse(value, out result)) { return(result); } return(defaultValue); }
public static void SetObject <T>(string key, T value) { MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, value); string result = Convert.ToBase64String(stream.GetBuffer()); PlayerPrefs.SetString(key, SecuritySystem.Encrypt(KEY, result)); stream.Close(); }
public static T GetObject <T>(string key) { string data = SecuritySystem.Decrypt(KEY, PlayerPrefs.GetString(key)); byte[] buffer = Convert.FromBase64String(data); MemoryStream stream = new MemoryStream(buffer); BinaryFormatter formatter = new BinaryFormatter(); stream.Position = 0; T result = (T)formatter.Deserialize(stream); stream.Close(); return(result); }
public static void SetString(string key, string value) { PlayerPrefs.SetString(key, SecuritySystem.Encrypt(KEY, value.ToString())); }