do you know how can I get the number of players in a specific scene? I'm using Unity Photon's PUN 2, so, almost anything of PUN 1 won't work. Thanks.
The PhotonNetwork class in the Photon.Pun namespace has a static property CurrentRoom where you can get the number of player in a room.
using Photon.Pun;
public static class MultiplayerHelper
{
public static int GetPlayerCount()
{
if (PhotonNetwork.CurrentRoom != null)
{
return PhotonNetwork.CurrentRoom.PlayerCount;
}
return 0;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.