注意客户端必须有localPlayerAuthority权限
public class NetworkPanel : MonoBehaviour { public Text textConnectionCount; private void Update() { if (NetworkServer.active) { ListvalueList = NetworkServer.objects.Values.ToList(); int playerCount = valueList.Count(item => item.localPlayerAuthority); textConnectionCount.text = playerCount.ToString(); } else { textConnectionCount.text = ""; } } }