public static bool TryLoad(DataName dataName, out float dataOut) { string key = "F_" + dataName.ToString(); dataOut = PlayerPrefs.GetFloat(key); return(PlayerPrefs.HasKey(key)); }
public static void ToStringTest(string value) { var instance = new DataName(value); var strValue = instance.ToString(); // セットした値と取得した値が一致すること Assert.AreEqual(strValue, value); }
public static void Save <T>(DataName dataName, T data) { string key = typeof(T) + "_" + dataName.ToString(); if (SavedData.TryGetValue(key, out object thisData)) { SavedData[key] = data; } else { SavedData.Add(key, data); } string JsonString = JsonConvert.SerializeObject(data); PlayerPrefs.SetString(key, JsonString); }
public static bool TryLoad <T>(DataName dataName, out T dataOut) { dataOut = default; string key = typeof(T) + "_" + dataName.ToString(); if (SavedData.TryGetValue(key, out object thisData)) { dataOut = (T)thisData; return(true); } if (PlayerPrefs.HasKey(key)) { string JsonString = PlayerPrefs.GetString(key, ""); dataOut = JsonConvert.DeserializeObject <T>(JsonString); SavedData.Add(key, dataOut); return(true); } Debug.LogWarning("Cannot Load Data : " + key); return(false); }
public static void Save(DataName dataName, float data) { string key = "F_" + dataName.ToString(); PlayerPrefs.SetFloat(key, data); }
public static void Save(DataName dataName, int data) { string key = "I_" + dataName.ToString(); PlayerPrefs.SetInt(key, data); }