12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using UnityEngine;
- using System.Collections;
- public class PlayerPrefsManager
- {
- public static void Set(string title, string label, object value)
- {
- string key = title+"_"+label;
- Set(key, value);
- }
- public static void Set(string title, int id, object value)
- {
- string key = title+"_"+id;
- Set(key, value);
- }
- public static void Set(string key, object value)
- {
- if(value.GetType().Equals(typeof(int)))
- {
- PlayerPrefs.SetInt(key, (int)value);
- }
- else if(value.GetType().Equals(typeof(float)))
- {
- PlayerPrefs.SetFloat(key, (float)value);
- }
- else if(value.GetType().Equals(typeof(string)))
- {
- PlayerPrefs.SetString(key, (string)value);
- }
- }
-
- public static int GetInt(string title, string id)
- {
- string key = title+"_"+id;
- return GetInt(key);
- }
- public static int GetInt(string key)
- {
- return PlayerPrefs.GetInt(key);
- }
-
- public static float GetFloat(string title, string id)
- {
- string key = title+"_"+id;
- return GetFloat(key);
- }
- public static float GetFloat(string key)
- {
- return PlayerPrefs.GetFloat(key);
- }
-
- public static string GetString(string title, string id)
- {
- string key = title+"_"+id;
- return GetString(key);
- }
- public static string GetString(string key)
- {
- return PlayerPrefs.GetString(key);
- }
-
- public static bool HasKey(string title, string label)
- {
- string key = title+"_"+label;
- return HasKey(key);
- }
- public static bool HasKey(string title, int id)
- {
- string key = title+"_"+id;
- return HasKey(key);
- }
-
- public static bool HasKey(string key)
- {
- return PlayerPrefs.HasKey(key);
- }
- public static void DeleteKey(string key)
- {
- PlayerPrefs.DeleteKey(key);
- }
- public static void DeleteAll()
- {
- PlayerPrefs.DeleteAll();
- }
- }
|