public static double?SetDoubleAndReturnPrevious(string key, double value) { double?result = null; if (UserPrefs.HasKey(key)) { string @string = PlayerPrefs.GetString(key); try { result = new double?(double.Parse(@string, NumberStyles.Float, NumberFormatInfo.InvariantInfo)); } catch (FormatException) { } catch (OverflowException) { } } UserPrefs.SetDouble(key, value); return(result); }