Example #1
0
    void GetRoomsInfo()
    {
        object[] roomsInfo;
        string   errInfo;

        if (NetCmdTranslator.Request(out errInfo, out roomsInfo, BR_Common.NetCmd.GetRoomsInfo, null))
        {
            //LobbyList.Clear();
            roomGrid.ClearAllChildGO();
            print("获取RoomsInfo成功!");
            for (int i = 0; i < roomsInfo.Length; i++)
            {
                //LobbyList.AddItem(string.Format("Lobby{0}: ({1})", i, (byte)roomsInfo[i]));
                Transform newRoom = Instantiate(roomTemplete) as Transform;
                //newRoom.localScale = Vector3.one;
                newRoom.FindChild("Label").GetComponent <UILabel>().text = string.Format("房间{0} : ({1})", i, roomsInfo[i]);
                roomGrid.AddChild(newRoom);
                print("添加新房间号成功!");
            }
            roomGrid.Reposition();
            foreach (var item in roomGrid.GetChildList())
            {
                item.localScale = Vector3.one;
            }
        }
        else
        {
            Debug.LogError("获取Rooms信息错误:" + errInfo);
        }
    }