GetRoomList() does not show any room when it called immediately after joining a lobby
Options
Hello,
I want the room list to be shown when a player joins a lobby, thus I use GetRoomList() in OnJoinedLobby(), like this:
However, if I call GetRoomList() in Awake(), the console will log the rooms existing in the lobby. And it would also work when I make a button and assign its Onclick to GetRoomList().
But I don't want GetRoomList() to be called in every frame, nor do I want to ask the players to press a button to show the room list. Anybody know why it does not work in OnJoinedLobby()?
I want the room list to be shown when a player joins a lobby, thus I use GetRoomList() in OnJoinedLobby(), like this:
public override void OnJoinedLobby() { foreach (RoomInfo room in PhotonNetwork.GetRoomList()) { Debug.Log("room name:" + room.Name + " " + room.PlayerCount); } }The console does not show anything.
However, if I call GetRoomList() in Awake(), the console will log the rooms existing in the lobby. And it would also work when I make a button and assign its Onclick to GetRoomList().
But I don't want GetRoomList() to be called in every frame, nor do I want to ask the players to press a button to show the room list. Anybody know why it does not work in OnJoinedLobby()?
0
Best Answers
-
I put GetRoomList() in OnReceivedRoomListUpdate(), and it works as what I want. Though I still don't know why it does not work in OnJoinedLobby().5
-
Hi @Philip_hu,
GetRoomList()
doesn't work inOnJoinedLobby()
callback because the room list is not available at this time and is first available whenOnReceivedRoomListUpdate()
has been called on the client for the first time.5
Answers
-
auto join lobby enabled ?0
-
Yes, it is enabled.0
-
I put GetRoomList() in OnReceivedRoomListUpdate(), and it works as what I want. Though I still don't know why it does not work in OnJoinedLobby().5
-
Hi @Philip_hu,
GetRoomList()
doesn't work inOnJoinedLobby()
callback because the room list is not available at this time and is first available whenOnReceivedRoomListUpdate()
has been called on the client for the first time.5