0

Currently I'm trying to make a matchmakingsystem for my game with the photon networkingsystem. I already can create rooms and join into them, however if I try to use the PhotonNetwork.getRoomList() function the array is always empty. Following the network status string I know that I am in the standard lobby.

My Code:

void fillBrowser()
{
    Debug.Log("Checking for Rooms");
    if(PhotonNetwork.insideLobby)
    {
        Debug.Log("Inside a Lobby");
        Debug.Log(PhotonNetwork.GetRoomList().ToString());
    }
}

Returns:

Checking for Rooms

Inside a Lobby

RoomInfo[]

3 Answers 3

0

The output RoomInfo[] says that it returned an array of RoomInfos. You get this output because you called ToString() on an array. Save the returned RoomInfo[] to a variable, loop through them, and see what info they contain.

void fillBrowser()
{
    Debug.Log("Checking for Rooms");
    if(PhotonNetwork.insideLobby)
    {
        Debug.Log("Inside a Lobby");
        var rooms = PhotonNetwork.GetRoomList();
        foreach(var room in rooms) 
             Debug.Log("Found room: " + room.ToString());
    }
}
4
  • I tried out your code and still only got the Checking for Rooms and Inside a Lobby returns. Does anybody know if the method if the Function GetRoomList is deprecated?
    – Mineorbit
    Sep 4, 2015 at 21:35
  • Then the enumeration which GetRoomLists() returns must be empty. Log rooms.Length to the console to make sure. Maybe this is also a problem related to forum.unity3d.com/threads/… Sep 4, 2015 at 21:44
  • When I try to monitor it it always stays zero. I am starting the room in a second client and check the list in a second client. Maybe my CreateRoom Code might be the error: RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 4 }; PhotonNetwork.CreateRoom("Test",roomOptions,TypedLobby.Default);
    – Mineorbit
    Sep 4, 2015 at 23:03
  • 1
    So have you tried setting the room's visibility to 'true' already? (isVisble = true) Sep 4, 2015 at 23:24
0
using System.Linq;

Debug.Log(string.Concat(GetRoomList().Select(x => x.name + "\n\r").ToArray()));

or

using System.Linq;

GetRoomList().ToList().ForEach(x => { Debug.Log(x.name); });
-1

Sorry m answering bit late.. just add "PhotonNetwork.autoJoinLobby = true;" in the void Awake() function and everything will work smoothly ;)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.