void AddNewCell(string h, string d, string q, string g) { GameObject newone = Instantiate(Resources.Load("ui/QuestionBlockToggle") as GameObject); if (newone != null) { newone.transform.SetParent(grid.transform); newone.transform.localScale = Vector3.one; newone.transform.position = Vector3.zero; RectTransform rti = newone.GetComponent <RectTransform>(); rti.anchoredPosition3D = new Vector3(rti.anchoredPosition3D.x, rti.anchoredPosition3D.y, 0); QuestionBlockCell qbc = newone.GetComponent <QuestionBlockCell>(); qbc.controller = this; qbc.hospitalNameText.text = h; qbc.departmentNameText.text = d; qbc.questionNameText.text = q; qbc.questionGuid = g; } else { Debug.Log("Instantiate QuestionBlockToggle failed."); #if UNITY_ANDROID Toast.ShowToast("未知错误,请退出后重试"); #endif } }
public void OnLoadBtnClick() { loadingPanel.SetActive(true); downloaded = 0; for (int i = 0; i < grid.transform.childCount; i++) { if (grid.transform.GetChild(i).gameObject.GetComponent <Toggle>().isOn) { QuestionBlockCell qbc = grid.transform.GetChild(i).gameObject.GetComponent <QuestionBlockCell>(); if (!PollsConfig.QuestionMap.ContainsKey(qbc.questionGuid)) { StartCoroutine(webLoadQuestions(qbc)); } } } }
IEnumerator webLoadQuestions(QuestionBlockCell qbc) { WWW www = new WWW("http://47.106.71.112:8080/api/Questions?questionname=" + qbc.questionGuid); yield return(www); if (www.isDone && www.error == null) { downloaded++; if (downloaded == grid.transform.childCount) { loadingPanel.SetActive(false); } parseJson(qbc.questionGuid, www.text); //add hospital PollsConfig.AddHospitals(qbc.hospitalNameText.text, 0); PollsConfig.AddDepartment(qbc.departmentNameText.text, 0, PollsConfig.GetHospitalCellInfoByName(qbc.hospitalNameText.text)); PollsConfig.DepartmentCellInfo dci = PollsConfig.GetDepartmentCellInfoByName(qbc.departmentNameText.text, PollsConfig.GetHospitalCellInfoByName(qbc.hospitalNameText.text)); dci.questions = PollsConfig.QuestionMap[qbc.questionGuid]; dci.qusetionLoaded = true; www.Dispose(); } }
public void OnCellToggle(bool b, QuestionBlockCell qbc) { }