public static int GetLenghtTableList(string keyTable) { string json = PlayerPrefs.GetString(keyTable); HighScoreTableData tableDataJsonUtility = JsonUtility.FromJson <HighScoreTableData>(json); return(tableDataJsonUtility.tableDataList.Count); }
public static void GetElementsList(string keyTable, int listIndex, out int score, out string name) { string json = PlayerPrefs.GetString(keyTable); HighScoreTableData tableDataJsonUtility = JsonUtility.FromJson <HighScoreTableData>(json); score = tableDataJsonUtility.tableDataList[listIndex].score; name = tableDataJsonUtility.tableDataList[listIndex].name; json = JsonUtility.ToJson(tableDataJsonUtility); PlayerPrefs.SetString(keyTable, json); PlayerPrefs.Save(); }
public static void SortTable(string keyTable) { string json = PlayerPrefs.GetString(keyTable); HighScoreTableData tableDataJsonUtility = JsonUtility.FromJson <HighScoreTableData>(json); if (tableDataJsonUtility.tableDataList.Count > 1) { tableDataJsonUtility.Sort(); } json = JsonUtility.ToJson(tableDataJsonUtility); PlayerPrefs.SetString(keyTable, json); PlayerPrefs.Save(); }
public static void CreatTable(string keyTable) { if (!PlayerPrefs.HasKey(keyTable)) { HighScoreTableData tableData = new HighScoreTableData(); tableData.tableDataList = new List <HighScoreData>(); string json = JsonUtility.ToJson(tableData); PlayerPrefs.SetString(keyTable, json); PlayerPrefs.Save(); } else { Debug.LogError("Ya existe esta llave"); } }
public static void AddElementToTable(string keyTable, int score, string name) { HighScoreData tableData = new HighScoreData(); tableData.score = score; tableData.name = name; string json = PlayerPrefs.GetString(keyTable); HighScoreTableData tableDataJsonUtility = JsonUtility.FromJson <HighScoreTableData>(json); tableDataJsonUtility.tableDataList.Add(tableData); json = JsonUtility.ToJson(tableDataJsonUtility); PlayerPrefs.SetString(keyTable, json); PlayerPrefs.Save(); }