Home > OS >  Unity PUN 2 Get Room Playercount Without Joining The Room
Unity PUN 2 Get Room Playercount Without Joining The Room

Time:05-05

i want to have a little player count next to each room in my room list but getting the playercount using playerCount.text = PhotonNetwork.PlayerList.Length.ToString(); wouldnt work because it will return 0 since you're not in a room yet.

CodePudding user response:

Room has a PlayerCount property

byte PlayerCount[get] The count of players in this Room (using this.Players.Count)

However, it seems to conflict with the Players property referenced above (using this.Players.Count).

Dictionary<int, Player> Players[get] While inside a Room, this is the list of players who are also in that room.

I would expect thisRoom.PlayerCount to work as expected, even though the documentation seems to state otherwise.

  • Related