PhotonNetwork.GetRoomList() doesnt work for me (kinda bug, but solved)
Options
lennart862
✭✭
I have a problem with PhotonNetwork.GetRoomList() because it always returns 0. I joined a room with one client and I joined the lobby with the editor.
My code:
void OnJoinedLobby()
{
if (PhotonNetwork.insideLobby)
{
Debug.Log("Rooms: " + PhotonNetwork.GetRoomList().Length);
Debug.Log("Room Count: " + PhotonNetwork.countOfRooms);
}
}
Output in Console:
Rooms: 0
Room Count: 1
---
So I just want all rooms in an array. Whats wrong with my code?
Thank you in advance!
My code:
void OnJoinedLobby()
{
if (PhotonNetwork.insideLobby)
{
Debug.Log("Rooms: " + PhotonNetwork.GetRoomList().Length);
Debug.Log("Room Count: " + PhotonNetwork.countOfRooms);
}
}
Output in Console:
Rooms: 0
Room Count: 1
---
So I just want all rooms in an array. Whats wrong with my code?
Thank you in advance!
0
Comments
-
Okay, I figured out why it doesn't work; just if anyone else has the same problem, here is the solution:
You cant call PhotonNetwork.GetRoomList() in the OnJoinedLobby function because Photon needs some time to send you all available rooms. So just create a new IEnumerator and wait for a second and call PhotonNetwork.GetRoomList() right after it. But I hope they fix it so the OnJoinedLobby function is called if the rooms are already sent because you can never know if the rooms are sent if the IEnumerator is finished0 -
0