Пример #1
0
        public void OnClickEnter()
        {
            if (group.select == null)
            {
                return;
            }
            ServerVO vo = group.select.GetComponent <ServerItem>().vo;

            Debug.Log(vo);

            GameConst.ServerID = vo.id;


            if (OnSelect != null)
            {
                OnSelect();
            }
        }
Пример #2
0
        IEnumerator SetList()
        {
            string url = PathUtil.DataUrl + GameConst.Platform_ServerFileName;

            WWW www = new WWW(url);

            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                yield break;
            }

            for (int i = 1; i < container.childCount; i++)
            {
                DestroyImmediate(container.GetChild(i).gameObject);
            }

            string[] lines = www.text.Split('\n');
            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                string[] csv = line.Split(';');

                ServerVO vo = new ServerVO();
                vo.id    = csv.GetInt32(0);
                vo.name  = csv.GetString(1);
                vo.ip    = csv.GetString(2);
                vo.state = (ServerVO.StateType)csv.GetInt32(3);
                voList.Add(vo);
            }


            for (int i = voList.Count - 1; i >= 0; i--)
            {
                GameObject go   = GameObject.Instantiate(itemPrefab);
                ServerItem item = go.GetComponent <ServerItem>();
                item.vo = voList[i];

                go.GetComponent <TabButton>().group = group;

                go.transform.SetParent(container);
                go.SetActive(true);

                if (GameConst.ServerID <= 0)
                {
                    if (i == voList.Count - 1)
                    {
                        group.select = go.GetComponent <TabButton>();
                    }
                }
                else if (GameConst.ServerID == item.vo.id)
                {
                    group.select = go.GetComponent <TabButton>();
                }
            }

            container.sizeDelta = new Vector2(container.sizeDelta.x, (50 + 5) * voList.Count);
        }