1
votes

really simple question really

how do i get this loop to show all players because its only showing my player. as you can see i tried starting a new line.

when i do the samestatment except playerlist i use otherlist it returns another player so why isnt the player list showing everyone :S

void openCloseScore()
{
    if (Input.GetKey (KeyCode.Tab)) 
    {
        ScoreBoard.SetActive (true);
        foreach(PhotonPlayer player in PhotonNetwork.playerList) 
        {
            ScoreboardTxt.text = "\r\nPlayerName:  " + player.ToString();
        }
    } 
    else 
    {
        ScoreBoard.SetActive(false);
    }
}
2
Every time you iterate through your foreach loop, ScoreboardTxt.text is being replaced. So the final item in PhotonNetwork.playerList will always show up. - jkerak

2 Answers

3
votes

Probably you should use += to concatenate all the players' data.

ScoreboardTxt.text += "\r\nPlayerName:  " + player.ToString();

Without the += ScoreboardTxt.text will only contain data about the last player.

0
votes

You're only showing the last player, not yours. You should add to the Text property, not repalce it.

void openCloseScore(){
  if (Input.GetKey (KeyCode.Tab)) {
      ScoreBoard.SetActive (true);
      foreach(PhotonPlayer player in PhotonNetwork.playerList) {
          //  ... change next line ...
          ScoreboardTxt.text += "\r\nPlayerName:  " + player.ToString(); // <------- change = to += in this line
    }
  } else {
    ScoreBoard.SetActive (false);
  }
}