public void LoadEnigmaDatas() { if (File.Exists(Application.persistentDataPath + "/enigmaData.dat")) { //get content of json string StreamReader file = new StreamReader(Application.persistentDataPath + "/enigmaData.dat"); string json = file.ReadToEnd(); //deserialize json string and put its content in List of Enigme_Data List <Enigme_Data> loadedDatas = new List <Enigme_Data>(); loadedDatas = JsonHelperList.FromJson <Enigme_Data>(json); file.Close(); //save the loaded data in the DataControl enigmaDatas = loadedDatas; } }
public void Load() { if (File.Exists(Application.persistentDataPath + "/playerInfo.dat")) { //get content of json string StreamReader file = new StreamReader(Application.persistentDataPath + "/playerInfo.dat"); string json = file.ReadToEnd(); //JsonUtility.FromJsonOverwrite(json, data); //deserialize json string and put its content in List of ScoreEnigme List <ScoreEnigme> loadedScores = new List <ScoreEnigme>(); loadedScores = JsonHelperList.FromJson <ScoreEnigme>(json); file.Close(); //save the loaded data in the DataControl save.scores = loadedScores; } }
public string getJSON() { Save data = new Save(); //Add the updated score to the Save ScoreEnigme score = new ScoreEnigme(); score.enigmaId = enigmaId; score.tentatives = tentatives; score.temps = Math.Round(temps, 2); score.aideExt = aideExt; score.enigmeReussie = enigmeReussie; List <ScoreEnigme> currentScores = save.Scores(); currentScores.Add(score); data.setScores(currentScores); save = data; bool prettyPrint = true; return(JsonHelperList.ToJson(currentScores, prettyPrint)); //serializing the list using a custom JsonHelper, adapting JsonUtility for Lists }