// Player connecting to your lobby public void addPlayer(string gameInfo, int connectionID) { messageLog.text = messageLog.text + "\nInside add player"; string[] playerInfo = gameInfo.Split(Convert.ToChar(Constants.gameDivider)); // Destroy everything in the panel foreach (Transform child in gameListCanvas.transform) { GameObject.Destroy(child.gameObject); } // Tell connecting player he failed to to join lobby, either it is full or we are not hosting if (!isHostingGame || !myGame.addPlayer()) { lobbyFull(connectionID); return; } // Create player class Player newplayer = new Player() { connectionID = connectionID, ipAddress = gameInfo }; lobbyPlayers.Add(newplayer); // Create UI GameObject to list player GameObject newPlayer = Instantiate(playerInfoPanel, gameListCanvas.transform, false); Text[] playerTexts = newPlayer.GetComponentsInChildren <Text>(); playerTexts[0].text = myGame.numberOfPlayers; playerTexts[1].text = playerInfo[1]; playerTexts[3].text = playerInfo[0]; }