简体   繁体   English

Unity Photon 可以查看当前玩家数量吗?

[英]Unity Photon can check current player count?

Now I test my demo game is used the free version that is only 20 ccu.现在我测试我的演示游戏使用的是只有 20 ccu 的免费版本。 I would like to ask how can I check how many players connect my photon server now.我想问一下我现在如何检查有多少玩家连接了我的光子服务器。 I want to do some waiting function if photon server has 20 players connected.如果光子服务器连接了 20 个玩家,我想做一些等待功能。 How can I check?我该如何检查? Thanks.谢谢。

You can get the count of currently online users connected to the lobby with the OnLobbyStatisticsUpdate() callback.您可以通过OnLobbyStatisticsUpdate()回调获取当前连接到大厅的在线用户数。 Your class must derive from Photon.PunBehaviour .您的课程必须派生自Photon.PunBehaviour

public override void OnLobbyStatisticsUpdate()
    {
        string countPlayersOnline;
        countPlayersOnline = PhotonNetwork.countOfPlayers.ToString() + " Players Online";
    }

Notice that this update comes with a correct value every 10 seconds (more or less depending on server load).请注意,此更新每 10 秒带有一个正确的值(或多或少取决于服务器负载)。

PhotonNetwork does not contain a defination for "countOfPlayers" PhotonNetwork 不包含“countOfPlayers”的定义

and now???现在???

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM