0

baically,当我调用它时,它只显示我的玩家姓名而不是其他人,但是当我将 foreach 循环更改为 foreach(PhotonNetwork.otherPlayers 中的 PhotonPlayer 玩家)时,它会返回另一个玩家,所以我哪里出错了?

这是只显示我的循环

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);
    }
   }

这个展示了其他玩家。这就是我知道上面的脚本应该吸引所有玩家的方式。

void openCloseScore(){
    if (Input.GetKey (KeyCode.Tab)) {
        ScoreBoard.SetActive (true);
        foreach(PhotonPlayer player in PhotonNetwork.otherPlayers) {
            ScoreboardTxt.text = "\r\nPlayerName:  " + player.ToString
                ();
        }
    } else {
        ScoreBoard.SetActive (false);
    }
   }

我需要循环向所有人展示。

4

0 回答 0