private void RoomRecived(RoomInfo room) { int index = RoomListingButtons.FindIndex(x => x.RoomName == room.Name); if (index == -1) { if (room.IsVisible && room.PlayerCount < room.MaxPlayers) { GameObject roomListingObj = Instantiate(RoomListingPrefab); roomListingObj.transform.SetParent(transform, false); RoomListing roomListing = roomListingObj.GetComponent <RoomListing>(); RoomListingButtons.Add(roomListing); index = RoomListingButtons.Count - 1; } } if (index != -1) { RoomListing roomListing = RoomListingButtons[index]; roomListing.SetRoomNameText(room.Name); roomListing.SetRoomPlayerCount(room.PlayerCount, room.MaxPlayers); roomListing.Updated = true; } }