How to make a Lobby Scene
Options
So I have been looking everywhere and I can't seem to find any instance of Photon or Unity being able to handle a Lobby Scene where when connected to the server, the UI shows all the available rooms that have been created. At best I can find some random connection setups but nothing that list off all the rooms. This is a good example of what I am talking about
I mean maybe not as complex with its information requirements. maybe just: Name of room, Number of players, If it's Password Protected (which is something I don't know how to do)
I think it has something to do with
I tried
If anyone has any ideas that would be helpful.
I mean maybe not as complex with its information requirements. maybe just: Name of room, Number of players, If it's Password Protected (which is something I don't know how to do)
I think it has something to do with
PhotonNetwork.GetRoomList
which I know is an array but I can't seem to write it out to be used.I tried
PhotonNetwork.countOfRooms
but even after telling the server to make multiple rooms it only counts 0.If anyone has any ideas that would be helpful.
0
Comments
-
Hi,
It's totally possible indeed.
PhotonNetwork.GetRoomList, but you need to catch OnReceivedRoomListUpdate and you need to be in a lobby, you could be connected to photon network but either not in the lobby or in a room.
Bye,
Jean
0 -
I made sure to already have Auto-join Lobby enabled and I also allready have:jeanfabre said:
PhotonNetwork.GetRoomList, but you need to catch OnReceivedRoomListUpdate and you need to be in a lobby, you could be connected to photon network but either not in the lobby or in a room.public void OnReceivedRoomListUpdate() { Debug.Log("room length : " + PhotonNetwork.GetRoomList().Length); }
I have 2 rooms spawned in:public void OnJoinedLobby(){ PhotonNetwork.CreateRoom ("Room1"); PhotonNetwork.CreateRoom (null);
and when I play in editor it only comes up as Room Length: 0.
When I play in editor with a build already up, it shows Room Length: 1.
So I am still lost.0 -
Hi,
Does it get corrected after a short while? or you never receive the OnReceivedRoomListUpdate to match the number of rooms actually created?
Bye,
Jean0 -
Just found this. I had the same problem once. You need to store the room list in a RoomInfo array.
Example >RoomInfo [] roomz = PhotonNetwork.GetRoomList (); foreach (RoomInfo room in roomz) { print (room.name + room.playerCount)}
This shows you how each of the room is named and how many players are in the particular room.0 -
Hi @SamPav,
I don't think the following code is correct:public void OnJoinedLobby(){ PhotonNetwork.CreateRoom ("Room1"); PhotonNetwork.CreateRoom (null);
You can't have 2 consecutive join or create. Once you create a room successfully you will switch servers and join it.0 -
Hi,
Indeed, JohnTub is right, you should create the room, and then wait for the OnJoinedRoom() callback or within the frame update check for PhotonNetwork.InRoom flag.
Bye,
Jean0