我已经在OnReceivedRoomListUpdate
函数中获得了房间列表,但最近,此函数内的PhotonNetwork.GetRoomList()
始终返回一个空数组。
这是我的代码:
public class RefreshRooms : Photon.PunBehaviour {
...
void Start () {
PhotonNetwork.autoJoinLobby = true;
...
Refresh();
}
// Update is called once per frame
void Update () {
// FYI: Here, PhotonNetwork.countOfPlayers gives the correct count of players currently in the lobby
}
...
public void Refresh()
{
...
PhotonNetwork.Disconnect();
PhotonNetwork.ConnectUsingSettings("v3");
}
void OnJoinedLobby()
{
// Display 'Fetching Rooms List...' message
...
}
void OnReceivedRoomListUpdate()
{
// Here PhotonNetowrk.GetRoomList().Length always gives 0, even if there are rooms
// Also, this function is getting called only once in the entire lifecycle
// FYI: PhotonNetwork.insideLobby gives true here
...
}
}
我正在使用PUN v1.51
。我现在需要实现的API有什么变化吗?
答案 0 :(得分:-1)
在Photon更新中看起来有些变化。更新Photon后,很多人都遇到了这个问题。您现在需要在调用此函数之前启用AutoJoinLobby
。
PhotonNetwork.autoJoinLobby = true;