void PopulateList() { foreach (var item in itemList) { GameObject newButton = Instantiate(sampleButton) as GameObject; SampleButtonScript labelButton = newButton.GetComponent <SampleButtonScript>(); labelButton.label.text = item.name; labelButton.button.onClick = item.thingsToDo; newButton.transform.SetParent(contentPanel, false); } }
void PopulateList() { foreach (var item in listaRetete) { GameObject newButton = Instantiate(sampleButton) as GameObject; SampleButtonScript buttonScript = newButton.GetComponent <SampleButtonScript> (); buttonScript.description.text = item.pasi; buttonScript.wow.sprite = item.wow; buttonScript.button.onClick = item.spreBucatar; newButton.transform.SetParent(contentPanel); } }
void PopulateList() { foreach (var item in itemList) { GameObject newButton = Instantiate(sampleButton) as GameObject; SampleButtonScript buttonScript = newButton.GetComponent <SampleButtonScript>(); buttonScript.nameLabel.text = item.name; buttonScript.scoreLabel.text = item.score; buttonScript.faceImage.sprite = item.face; buttonScript.starImage.SetActive(item.isChampion); buttonScript.button.onClick = item.thingToDo; newButton.transform.SetParent(contentPanel); } }
IEnumerator GetData() { WWW www = new WWW(queryURL + "?category=" + categoryIden.value + "&keyword=" + searchInput.text); //GET data is sent via the URL while (!www.isDone && string.IsNullOrEmpty(www.error)) { yield return(null); } if (string.IsNullOrEmpty(www.error)) { string[] Allresult = www.text.Split("#".ToCharArray()); string[] result = Allresult[0].Split(";".ToCharArray()); string[] result2 = Allresult[1].Split(";".ToCharArray()); for (int i = 0; i < (int)(result.Length / 5); i++) { /*int check = 0; * if (result[i * 5 + 1].Contains(keyword)) check++; * if (result[i * 5 + 2].Contains(keyword)) check++; * if (result[i * 5 + 3].Contains(keyword)) check++; * if (result[i * 5 + 4].Contains(keyword)) check++; * //Debug.Log(check); * if (check == 0) continue;*/ GameObject newResult = Instantiate(searchResult) as GameObject; SampleButtonScript buttonScript = newResult.GetComponent <SampleButtonScript>(); int bd = i * 5 + 2; int fl = i * 5 + 3; //buttonScript.section.gameObject.SetActive(false); //buttonScript.time.gameObject.SetActive(false); buttonScript.nameLabel.text = result[i * 5 + 1]; //Debug.Log(result[i*5 + 1]); buttonScript.placeLabel.text = result[bd] + ", Floor " + result[fl] + ", Room " + result[i * 5 + 4]; //Debug.Log(result[i*5 + 2]); /*WWW wwwimg = new WWW(imgURL + result[i * 5] + ".png"); * while (!wwwimg.isDone && string.IsNullOrEmpty(wwwimg.error)) * { * yield return null; * } * buttonScript.exImage.texture = wwwimg.texture;*/ string ori_roomname = result[i * 5 + 4]; string roomname = ori_roomname.Replace("/", string.Empty); roomname = roomname.Replace(".", string.Empty); //Debug.Log("roomname : "+roomname); GameObject target = FindObject(result[bd], result[fl], roomname); //Debug.Log("target1 : "+target.name); buttonScript.button.onClick.AddListener(() => ChangeUI(newResult, target, ori_roomname)); buttonScript.button.onClick.AddListener(() => ShowOnlyTargetObject(result[bd], result[fl])); buttonScript.button.onClick.AddListener(() => ChangeCameraView(target)); newResult.transform.SetParent(contentPanel); newResult.transform.localScale = new Vector3(1, 1, 1); items.Add(buttonScript); //Debug.Log("finish"); } for (int i = 0; i < (int)(result2.Length / 7); i++) { GameObject newResult = Instantiate(searchResult) as GameObject; SampleButtonScript buttonScript = newResult.GetComponent <SampleButtonScript>(); int bd = i * 7 + 2; int fl = i * 7 + 3; buttonScript.nameLabel.text = result2[i * 7] + " " + result2[i * 7 + 1]; buttonScript.placeLabel.text = result2[bd] + ", Floor " + result2[fl] + ", Room " + result2[i * 7 + 4]; buttonScript.section.text = "SEC " + result2[i * 7 + 5]; string sptemp = result2[i * 7 + 6]; string spday = "", sptime = ""; for (int x = 0; x < sptemp.Length; ++x) { if (sptemp[x] >= '0' && sptemp[x] <= '9') { spday = sptemp.Substring(0, (x - 1)); sptime = sptemp.Substring(x); break; } } buttonScript.day.text = spday; buttonScript.time.text = sptime; buttonScript.section.gameObject.SetActive(true); buttonScript.day.gameObject.SetActive(true); buttonScript.time.gameObject.SetActive(true); string ori_roomname = result2[i * 7 + 4]; string roomname = ori_roomname.Replace("/", string.Empty); roomname = roomname.Replace(".", string.Empty); //Debug.Log("roomname : " + roomname); GameObject target = FindObject(result2[bd], result2[fl], roomname); //Debug.Log("FL : " + fl); buttonScript.button.onClick.AddListener(() => ChangeUI(newResult, target, ori_roomname)); buttonScript.button.onClick.AddListener(() => ShowOnlyTargetObject(result2[bd], result2[fl])); buttonScript.button.onClick.AddListener(() => ChangeCameraView(target)); newResult.transform.SetParent(contentPanel); newResult.transform.localScale = new Vector3(1, 1, 1); items.Add(buttonScript); } for (int i = 0; i < (int)(result.Length / 5); i++) { WWW wwwimg = new WWW(imgURL + result[i * 5] + ".jpg"); while (!wwwimg.isDone && string.IsNullOrEmpty(wwwimg.error)) { yield return(null); } if (string.IsNullOrEmpty(wwwimg.error)) { items[i].exImage.texture = wwwimg.texture; items[i].exImage.color = Color.white; items[i].mask.gameObject.SetActive(true); } } items.Clear(); } else { Debug.LogWarning(www.error); } }