ball 项目提交
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public static class PlayerPrefsKit
|
||||
{
|
||||
public static void WriteInt(string key, int data)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, data);
|
||||
}
|
||||
|
||||
public static void WriteBool(string key, bool data)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, data ? PrefsConst.IntTrue : PrefsConst.IntFalse);
|
||||
}
|
||||
|
||||
public static void WriteString(string key, string data)
|
||||
{
|
||||
PlayerPrefs.SetString(key, data);
|
||||
}
|
||||
|
||||
public static void WriteObject(string key, object data)
|
||||
{
|
||||
string dataStr = SerializeUtil.ToJson(data);
|
||||
PlayerPrefs.SetString(key, dataStr);
|
||||
}
|
||||
|
||||
public static bool ReadBool(string key, bool defalutValue = PrefsConst.BoolDefault)
|
||||
{
|
||||
if (!HasKey(key))
|
||||
{
|
||||
return defalutValue;
|
||||
}
|
||||
|
||||
bool data = PlayerPrefs.GetInt(key) == PrefsConst.IntTrue ? true : false;
|
||||
return data;
|
||||
}
|
||||
|
||||
public static string ReadString(string key)
|
||||
{
|
||||
string data = PlayerPrefs.GetString(key, string.Empty);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool HasKey(string key)
|
||||
{
|
||||
return PlayerPrefs.HasKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user