GetRoomList() 总是 returns 空数组
GetRoomList() always returns empty array
我一直在 OnReceivedRoomListUpdate
函数中得到房间列表,但最近,这个函数中的 PhotonNetwork.GetRoomList()
总是 returns 一个空数组。
这是我的代码:
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 有什么变化吗?
似乎在 Photon 更新中发生了一些变化。许多人在更新 Photon 后遇到了这个问题。您现在需要在调用此函数之前启用 AutoJoinLobby
。
PhotonNetwork.autoJoinLobby = true;
我一直在 OnReceivedRoomListUpdate
函数中得到房间列表,但最近,这个函数中的 PhotonNetwork.GetRoomList()
总是 returns 一个空数组。
这是我的代码:
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 有什么变化吗?
似乎在 Photon 更新中发生了一些变化。许多人在更新 Photon 后遇到了这个问题。您现在需要在调用此函数之前启用 AutoJoinLobby
。
PhotonNetwork.autoJoinLobby = true;