Beispiel #1
0
    // Token: 0x06001C2C RID: 7212 RVA: 0x0008F334 File Offset: 0x0008D534
    public static T ReadKey <T>(CmunePrefs.Key k, T defaultValue)
    {
        T result = defaultValue;

        if (typeof(T) == typeof(bool))
        {
            result = (T)((object)(PlayerPrefs.GetInt(k.ToString(), (!(bool)((object)defaultValue)) ? 0 : 1) == 1));
        }
        else if (typeof(T) == typeof(int))
        {
            result = (T)((object)PlayerPrefs.GetInt(k.ToString(), (int)((object)defaultValue)));
        }
        else if (typeof(T) == typeof(float))
        {
            result = (T)((object)PlayerPrefs.GetFloat(k.ToString(), (float)((object)defaultValue)));
        }
        else if (typeof(T) == typeof(string))
        {
            result = (T)((object)PlayerPrefs.GetString(k.ToString(), (string)((object)defaultValue)));
        }
        else
        {
            Debug.LogError(string.Format("Key {0} couldn't be read because type {1} not supported.", k, typeof(T)));
        }
        return(result);
    }
Beispiel #2
0
 // Token: 0x06001C2A RID: 7210 RVA: 0x0008F2E8 File Offset: 0x0008D4E8
 public static bool TryGetKey <T>(CmunePrefs.Key k, out T value)
 {
     if (PlayerPrefs.HasKey(k.ToString()))
     {
         value = CmunePrefs.ReadKey <T>(k, default(T));
         return(true);
     }
     value = default(T);
     return(false);
 }
Beispiel #3
0
 // Token: 0x06001C2E RID: 7214 RVA: 0x0008F49C File Offset: 0x0008D69C
 public static void WriteKey <T>(CmunePrefs.Key k, T val)
 {
     if (typeof(T) == typeof(bool))
     {
         PlayerPrefs.SetInt(k.ToString(), (!(bool)((object)val)) ? 0 : 1);
     }
     else if (typeof(T) == typeof(int))
     {
         PlayerPrefs.SetInt(k.ToString(), (int)((object)val));
     }
     else if (typeof(T) == typeof(float))
     {
         PlayerPrefs.SetFloat(k.ToString(), (float)((object)val));
     }
     else if (typeof(T) == typeof(string))
     {
         PlayerPrefs.SetString(k.ToString(), (string)((object)val));
     }
     else
     {
         Debug.LogError(string.Format("Key {0} couldn't be read because type {1} not supported.", k, typeof(T)));
     }
 }
Beispiel #4
0
 // Token: 0x06001C2D RID: 7213 RVA: 0x0008F480 File Offset: 0x0008D680
 public static T ReadKey <T>(CmunePrefs.Key k)
 {
     return(CmunePrefs.ReadKey <T>(k, default(T)));
 }
Beispiel #5
0
 // Token: 0x06001C2B RID: 7211 RVA: 0x00012B8B File Offset: 0x00010D8B
 public static bool HasKey(CmunePrefs.Key k)
 {
     return(PlayerPrefs.HasKey(k.ToString()));
 }