public StandtaskJSONClass(StandtaskJSONClass standtaskObject) { standtask_id = standtaskObject.standtask_id; standtask_name = standtaskObject.standtask_name; conn_json = standtaskObject.conn_json; rope_json = standtaskObject.rope_json; }
public void SaveFullStandtask(bool isStudent) { int standtask_id = 0; if (!isStudent) int.TryParse(SaveStandtaskID.text, out standtask_id); else int.TryParse(SaveStudentStandtaskID.text, out standtask_id); StandtaskJSONClass standtaskJSON = new StandtaskJSONClass(standtask_id, "", ropeManager.EncodeCurrentConnectionsToJSON(), ropeManager.EncodeAllRopesToJSON()); string FullStantaskJSON = standtaskJSON.GetJSON(); string fileName = "standtask_" + standtask_id + ".json"; string folderPath; //Debug.Log("Directory.GetCurrentDirectory" + Directory.GetCurrentDirectory()); if (FolderName != "") { folderPath = Application.dataPath + "/../" + FolderName + "/"; } else { folderPath = Application.dataPath + "/../"; } Debug.Log("folderPath: " + folderPath); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); Debug.Log("folder doesn't exist"); Directory.CreateDirectory(FolderName); Debug.Log("folder was created"); } else { Debug.Log("folder alredy exist"); } //Directory.CreateDirectory(folderName); if (File.Exists(fileName)) { Debug.Log(fileName + " already exists."); return; } //StreamWriter sr = File.CreateText(folderPath + fileName); File.WriteAllText(folderPath + fileName, FullStantaskJSON); //sr.Write(FullStantaskJSON); //sr.WriteLine("This is my file."); //sr.WriteLine("I can write ints {0} or floats {1}, and so on.", 1, 4.2); //sr.Close(); }
public void LoadFullStandtask(bool isStudent) { string folderPath = ""; string fileName = ""; if(!isStudent) fileName = "standtask_" + LoadStandtaskID.text + ".json"; else fileName = "standtask_" + LoadStudentStandtaskID.text + ".json"; //string JSONArrayWithRopes = ""; //Debug.Log("Directory.GetCurrentDirectory" + Directory.GetCurrentDirectory()); if (FolderName != "") { folderPath = Application.dataPath + "/../" + FolderName + "/"; } else { folderPath = Application.dataPath + "/../"; } StandtaskJSONClass standtask = new StandtaskJSONClass(File.ReadAllText(folderPath + fileName)); ropeManager.CreateRopesFromJSON(standtask.rope_json); }