IEnumerator SendPost(string url, WWWForm form) { WWW www = new WWW(url, form); yield return(www); if (www.error != null) { Debug.Log("error"); Debug.Log(www.error); } else { Debug.Log(www.text); if (www.text == "empty") { Debug.Log("empty!!!!!!"); GameObject cell = Instantiate(tableViewCell); cell.transform.SetParent(view.transform, false); UITableViewCell tableViewCellScript = cell.GetComponent <UITableViewCell>(); tableViewCellScript.UserRank = "No "; tableViewCellScript.UserName = "******"; tableViewCellScript.SetIcon(icon); tableViewCellScript.UserScore = "0"; } else { var received_data = Regex.Split(www.text, "</next>"); int num = (received_data.Length - 1) / 2; for (int i = 0; i < num; i++) { GameObject cell = Instantiate(tableViewCell); cell.transform.SetParent(view.transform, false); UITableViewCell tableViewCellScript = cell.GetComponent <UITableViewCell>(); tableViewCellScript.UserRank = (i + 1).ToString(); tableViewCellScript.UserName = received_data[2 * i]; tableViewCellScript.UserScore = received_data[2 * i + 1]; if (i < 3) { tableViewCellScript.SetIcon(icon); } if (i == 9) { break; } } } } }
// Use this for initialization void Start() { float height = tableView.rect.height; if (height < 100 * cells) { height = 100 * cells; } view.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); view.SetPositionAndRotation(new Vector3(0, -height / 2, 0), Quaternion.Euler(0, 0, 0)); for (int i = 0; i < cells; i++) { GameObject cell = Instantiate(tableViewCell); cell.transform.SetParent(view.transform, false); UITableViewCell tableViewCellScript = cell.GetComponent <UITableViewCell>(); tableViewCellScript.BookTitle = "Book " + (i + 1); tableViewCellScript.BookAuthor = "Author"; tableViewCellScript.SetIcon(icon); tableViewCellScript.PageReaded = (i + 1) * 3; } }