private void AddNewRoomListItems() { foreach (RoomInfo roomInfo in cachedRooms.Values) { Debug.Log("Creating room list item..."); GameObject newItem = Instantiate <GameObject>(RoomListItemPrefab, RoomListItemsPanel.transform, false); RoomListItemController controller = newItem.GetComponent <RoomListItemController>(); rooms.Add(roomInfo.Name, newItem); controller.RoomId = roomInfo.Name; Debug.Log(roomInfo.CustomProperties[MASTERPLAYERNAMEPROPERTY]); string opponent = roomInfo.CustomProperties[MASTERPLAYERNAMEPROPERTY].ToString(); controller.MasterPlayerName = opponent; controller.buttonText.text = controller.MasterPlayerName; controller.button.onClick.AddListener(delegate { OnRoomButtonClicked(roomInfo.Name, opponent); }); } }
private void AddNewRoomListItems(List <RoomInfo> roomList) { foreach (RoomInfo roomInfo in roomList) { if (!rooms.ContainsKey(roomInfo.Name) && roomInfo.IsOpen && roomInfo.IsVisible) { Debug.Log("Creating room list item..."); GameObject newItem = Instantiate <GameObject>(RoomListItemPrefab, RoomListItemsPanel.transform, false); RoomListItemController controller = newItem.GetComponent <RoomListItemController>(); rooms.Add(roomInfo.Name, newItem); controller.RoomId = roomInfo.Name; Debug.Log(roomInfo.CustomProperties[MASTERPLAYERNAMEPROPERTY]); controller.MasterPlayerName = roomInfo.CustomProperties[MASTERPLAYERNAMEPROPERTY].ToString(); controller.buttonText.text = controller.MasterPlayerName; controller.button.onClick.AddListener(delegate { OnRoomButtonClicked(roomInfo.Name); }); } } }