public void applyForPhases(string json) { Dictionary <int, Dictionary <string, string> > allPhases = new Dictionary <int, Dictionary <string, string> >(); List <object> respList = DeserializeJson <List <object> >(json); int i = 0; // destroyChilds(phaseItemContainer); // destroyList(phases); foreach (object obj in respList) { Dictionary <string, object> resp = DeserializeJson <Dictionary <string, object> >(obj.ToString()); Dictionary <string, string> phaseData = new Dictionary <string, string>(); phaseData.Add("name", resp["name"].ToString()); phaseData.Add("description", resp["description"].ToString()); phaseData.Add("priority", resp["priority"].ToString()); phaseData.Add("id", resp["id"].ToString()); phaseData.Add("fk_id_project", resp["fk_id_project"].ToString()); allPhases.Add(i, phaseData); i++; } foreach (KeyValuePair <int, Dictionary <string, string> > project in allPhases) { GameObject toAdd = Instantiate(phaseItem) as GameObject; toAdd.transform.Find("PhaseName").GetComponent <TextMeshProUGUI>().text = project.Value["name"]; toAdd.transform.Find("Index").GetComponent <TextMeshProUGUI>().text = project.Value["priority"]; ModifyRessourceButton toAddScr = toAdd.transform.Find("EditButton").GetComponent <ModifyRessourceButton>(); RemovePhaseButton rmScr = toAdd.transform.Find("RemoveButton").GetComponent <RemovePhaseButton>(); toAddScr.setIdToModify(project.Value["id"]); toAddScr.setProjectId(project.Value["fk_id_project"]); toAddScr.setProjectName(projectName); rmScr.setIdToRemove(int.Parse(project.Value["id"])); rmScr.setProjectId(project.Value["fk_id_project"]); rmScr.setProjectName(projectName); toAdd.transform.SetParent(phaseItemContainer.transform, false); // phases.Add(toAdd); } scr.SetActive(true); }
public void applyForRessource(string json) { Dictionary <int, Dictionary <string, string> > allRessource = new Dictionary <int, Dictionary <string, string> >(); List <object> respList = DeserializeJson <List <object> >(json); imgHandler = GameObject.Find("ImageHandler").GetComponent <ImageHandler>(); int i = 0; destroyChilds(listOfRess); // destroyList(ressources); foreach (object obj in respList) { Dictionary <string, object> resp = DeserializeJson <Dictionary <string, object> >(obj.ToString()); Dictionary <string, string> ressourceData = new Dictionary <string, string>(); ressourceData.Add("name", resp["name"].ToString()); ressourceData.Add("description", resp["description"].ToString()); ressourceData.Add("id", resp["id"].ToString()); ressourceData.Add("fk_id_project", resp["fk_id_project"].ToString()); ressourceData.Add("img_id", resp["img_id"].ToString()); allRessource.Add(i, ressourceData); i++; } foreach (KeyValuePair <int, Dictionary <string, string> > project in allRessource) { GameObject toAdd = Instantiate(elemInList) as GameObject; toAdd.transform.Find("RessourceName").GetComponent <TextMeshProUGUI>().text = project.Value["name"]; toAdd.transform.Find("RessourceDesc").GetComponent <TextMeshProUGUI>().text = project.Value["description"]; ModifyRessourceButton toAddScr = toAdd.GetComponent <ModifyRessourceButton>(); toAddScr.setIdToModify(project.Value["id"]); toAddScr.setProjectId(project.Value["fk_id_project"]); toAddScr.setProjectName(projectName); toAdd.transform.SetParent(listOfRess.transform, false); toAdd.GetComponent <Image>().sprite = imgHandler.GetSprite(int.Parse(project.Value["img_id"])); // ressources.Add(toAdd); } }