IEnumerator _FillRankItem(List <RankItemData> listData) { // Destroy all items for (int i = 0; i < itemsGrid.childCount; i++) { GameObject.Destroy(itemsGrid.GetChild(i).gameObject); } yield return(new WaitForEndOfFrame()); itemsGrid.GetComponent <UIGrid>().Reposition(); // fill items by context rank data for (int i = 0; i < listData.Count; i++) { GameObject item = NGUITools.AddChild(itemsGrid.gameObject, itemTemplate); UIRankItem itemScript = item.GetComponent <UIRankItem>(); RankItemData itemData = listData[i]; string playerName = itemData.playerName; string headIcon = itemData.headIcon; itemScript.InitItem(playerName, headIcon); } itemsGrid.GetComponent <UIGrid>().Reposition(); }
IEnumerator _FileRankItem() { // Destroy all items for (int i = 0; i < itemsGrid.childCount; i++) { GameObject.Destroy(itemsGrid.GetChild(i).gameObject); } yield return(new WaitForEndOfFrame()); itemsGrid.GetComponent <UIGrid>().Reposition(); // fill items by given data for (int i = 0; i < 10; i++) { GameObject item = NGUITools.AddChild(itemsGrid.gameObject, itemTemplate); UIRankItem itemScript = item.GetComponent <UIRankItem>(); string playerName = headIcons[UnityEngine.Random.Range(0, headIcons.Length)]; string headIcon = "Emoticon - " + playerName; itemScript.InitItem("Mr." + playerName, headIcon); } itemsGrid.GetComponent <UIGrid>().Reposition(); }