我已經在OnReceivedRoomListUpdate
函數中獲得了房間列表,但是最近這個函數裏面的PhotonNetwork.GetRoomList()
總是返回一個空數組。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有沒有變化?
返回數組的長度是多少?此外,請發佈您如何使用此功能 – Programmer
@Programmer PhotonNetwork.GetRoomList()。長度爲0,此外,OnReceivedRoomListUpdate()函數總是在整個生命週期中調用一次 –