Demo rank item to show the rank detail content
Inheritance: UnityEngine.MonoBehaviour
Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }