Ejemplo n.º 1
0
 public static T GetSetting <T>(AppSetting.PrefKey <T> key)
 {
     if (PlayerPrefs.HasKey(key.path))
     {
         string value = PlayerPrefs.GetString(key.path);
         if (typeof(T).IsValueType || typeof(T) == typeof(string))
         {
             var foo = TypeDescriptor.GetConverter(typeof(T));
             return((T)(foo.ConvertFromInvariantString(value)));
         }
         else
         {
             T re = JsonMapper.ToObject <T>(value);
             return(re);
         }
     }
     else
     {
         return(key.defaultValue);
     }
 }
Ejemplo n.º 2
0
        public static void SetSetting <T>(AppSetting.PrefKey <T> key, T value)
        {
            var content = typeof(T).IsValueType ? value.ToString() : JsonMapper.ToJson(value);

            PlayerPrefs.SetString(key.path, content);
        }