bingo 项目提交
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BingoBrain.Core
|
||||
{
|
||||
public static class RrysKit
|
||||
{
|
||||
public static void WriteInt(string key, int data)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, data);
|
||||
}
|
||||
|
||||
public static void WriteBool(string key, bool data)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, data ? FsConst.IntTrue : FsConst.IntFalse);
|
||||
}
|
||||
|
||||
public static void WriteObject(string key, object data)
|
||||
{
|
||||
string dataStr = Havva.ToJson(data);
|
||||
PlayerPrefs.SetString(key, dataStr);
|
||||
}
|
||||
|
||||
public static bool ReadBool(string key, bool defalutValue = FsConst.BoolDefault)
|
||||
{
|
||||
if (!HasKey(key))
|
||||
{
|
||||
return defalutValue;
|
||||
}
|
||||
|
||||
bool data = PlayerPrefs.GetInt(key) == FsConst.IntTrue ? true : false;
|
||||
return data;
|
||||
}
|
||||
|
||||
public static object ReadObject<T>(string key)
|
||||
{
|
||||
if (!HasKey(key))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string dataStr = PlayerPrefs.GetString(key);
|
||||
if (string.IsNullOrEmpty(dataStr))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
T data = Havva.ToObject<T>(dataStr);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool HasKey(string key)
|
||||
{
|
||||
return PlayerPrefs.HasKey(key);
|
||||
}
|
||||
|
||||
public static void DeleteKey(string key)
|
||||
{
|
||||
if (HasKey(key))
|
||||
{
|
||||
PlayerPrefs.DeleteKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user