Beispiel #1
0
    public void AddRoomBox(string ip, Room room)
    {
        string title     = room.Title;
        int    headCount = room.HeadCount;
        int    maxUser   = room.MaxUser;

        GameObject listBox = Instantiate(roomPrefab, Vector2.zero, Quaternion.identity);

        listBox.name = ip;
        listBox.transform.SetParent(roomListPanel.transform);
        listBox.transform.localScale = new Vector3(1, 1, 1);
        ServerViewer roomViewer = listBox.GetComponent <ServerViewer>();

        roomViewer.Keep(ip, room, 15f);

        roomList.Add(ip, roomViewer);

        /* RoomViewer에서 처리
         *
         * Transform listBoxTr = listBox.transform;
         *
         * Text titleText = listBoxTr.GetChild(0).GetComponent<Text>();
         * Text UserStatText = listBoxTr.GetChild(1).GetComponent<Text>();
         *
         * titleText.text = title;
         * UserStatText.text = headCount.ToString() + "/" + maxUser.ToString();
         */

        Button button = listBox.GetComponent <Button>();

        button.onClick.AddListener(() => ClickRoomBox(listBox.name));
    }
Beispiel #2
0
    public void RemoveRoomBox(string ip)
    {
        if (roomList.ContainsKey(ip))
        {
            ServerViewer viewer = roomList[ip];
            Destroy(viewer.gameObject);
            roomList.Remove(ip);
        }

        /*
         * GameObject removeListBox = listBoxes.Find(x => x.name.Equals(ip));
         * if(removeListBox != null)
         * {
         *  listBoxes.Remove(removeListBox);
         *  Destroy(removeListBox);
         * }
         */
    }