public void OpenDetail(NewsboardDetail data) { link = null; Debug.Log("OpenDetail"); #if !UNITY_WEBGL && !DISABLE_WEBVIEW _webView.Hide(); #endif nDetail = data; this.gameObject.SetActive(true); setupDetailData(); StopCoroutine("ContentShow"); StopCoroutine("ContentHide"); //start coroutine StartCoroutine("ContentShow"); }
void createNewsContentData(NewsboardDetail nDetail) { if (nDetail.pin != "1") { GameObject itemDetail = (GameObject)GameObject.Instantiate(News); itemDetail.SetActive(true); itemDetail.transform.parent = this.transform; itemDetail.transform.localPosition = new Vector3(0, -1.8f - (countNews + countPragard) * 0.83f, 0); NewsboardContent idt = itemDetail.GetComponent <NewsboardContent>(); idt.setContent(nDetail); newsList.Add(itemDetail); countNews++; } }
public void SetContent(NewsboardDetail data) { ClearContent(); cData = data; float heightSummary = 0; Debug.Log("Title : " + StringUtil.ParseUnicodeEscapes(data.title)); titleText.text = "<b>" + StringUtil.ParseUnicodeEscapes(data.title) + "</b>"; titleText.ForceMeshUpdate(); heightSummary -= (titleText.bounds.size.y + 0.5f - titleText.transform.localPosition.y); //max content int maxObj = (data.desc.Length > data.img.Length) ? data.desc.Length : data.img.Length; for (int i = 0; i < maxObj; i++) { GameObject cObj = (GameObject)GameObject.Instantiate(ContentObjectPrefabs); cObj.SetActive(true); cObj.name = "Paragraph" + (i + 1); cObj.transform.parent = this.transform; NewsboardContentObject cComp = cObj.GetComponent <NewsboardContentObject>(); //setup component if (i < data.img.Length) { cComp.setupImg(data.img[i], i); } if (i == 0) { cComp.setupDetailText(data.desc[i]); } Debug.Log("Hight Summary : " + heightSummary); cObj.transform.localPosition = new Vector3(0, heightSummary, 0); if (data.desc[i] == "") { detailHeight = 0.5f; } else { detailHeight = 0.0f; } heightSummary -= (cComp.height - detailHeight + 0.5f); ObjectList.Add(cObj); ContentList.Add(cComp); } height = -heightSummary; }
public void setContent(NewsboardDetail nDetail) { NewsDetail = nDetail; TextTitle.text = nDetail.title; linkweb = nDetail.link_web; if (nDetail.pin == "1") { pragardIcon.SetActive(true); } else { if (nDetail.hot == "1") { hotIcon.SetActive(true); } } }
public IEnumerator DownloadJSON(string url) { url = UserCommonData.GetURL() + url + "&type=0&offset=0&limit=9&sort=0&cat=0"; www = new WWW(url); Debug.Log("Start Download News Board JSON : " + url); yield return(new WaitForSeconds(3f)); while (!www.isDone) { yield return(null); } yield return(www); /* EDIT: */ if (!string.IsNullOrEmpty(www.error)) { PopupObject.ShowAlertPopup("พบปัญหาในการเชื่อมต่อ", "ไม่สามารถตรวจสอบข้อมูลของท่านได้ กรุณาตรวจสอบอินเทอร์เน็ตของท่าน และลองใหม่อีกครั้ง", "ตกลง", null); Debug.LogWarning("LOCAL FILE ERROR: " + www.error); } else { JSONObject j = new JSONObject(www.text); Debug.Log("JSONObject : " + www.text); JSONObject arr = j["Result"]; Debug.Log("All News : " + arr.list.Count); contentList = new NewsboardDetail[arr.list.Count]; //loop for Result int i = 0; foreach (JSONObject content in arr.list) { NewsboardDetail data = new NewsboardDetail(); data.title = StringUtil.ParseUnicodeEscapes(content["title"].str); // data.desc = content["desc"].str; JSONObject descList = content["desc"]; data.desc = new string[descList.list.Count]; int k = 0; if (descList != null) { foreach (JSONObject desc in descList.list) { string tempdesc = desc.str.Replace(@"\/", @"/"); data.desc[k] = tempdesc; k++; } } JSONObject imgList = content["img"]; data.img = new string[imgList.list.Count]; k = 0; if (imgList != null) { foreach (JSONObject img in imgList.list) { string tempimg = img.str.Replace(@"\/", @"/"); data.img[k] = tempimg; k++; } } data.status = content["status"].str; data.type = content["type"].str; data.date = content["date"].str; data.link_web = content["link_web"].str; data.hot = content["hot"].str; data.pin = content["pin"].str; contentList[i] = data; i++; } isFinish = true; if (postDownloaded != null) { postDownloaded(); } } }