public static void SaveToolDataStatus(ToolSaveData saveData) { List <ToolSaveData> oldDatas = LoadToolDataStatus(); ToolSaveData oldData = oldDatas.Find(y => saveData.name == y.name); if (oldData != null) { oldData.SetValue(saveData); } else { oldDatas.Add(saveData); } SaveDataList(oldDatas); }
public static void SaveToolDataStatus(List <ToolSaveData> saveDataList) { List <ToolSaveData> oldDatas = LoadToolDataStatus(); saveDataList.ForEach(x => { ToolSaveData oldData = oldDatas.Find(y => x.name == y.name); if (oldData != null) { oldData.SetValue(x); } else { oldDatas.Add(x); } }); SaveDataList(oldDatas); }
public static List <ToolSaveData> LoadToolDataStatus() { List <ToolSaveData> saveDataList = new List <ToolSaveData>(); string str = PlayerPrefs.GetString(SaveKey); string[] strArray = str.Split('|'); for (int i = 0; i < strArray.Length; i++) { if (string.IsNullOrEmpty(strArray[i])) { continue; } ToolSaveData saveData = JsonUtility.FromJson <ToolSaveData>(strArray[i]); saveDataList.Add(saveData); } return(saveDataList); }
public void SetValue(ToolSaveData data) { name = data.name; isShow = data.isShow; }