GetRoomList() not Work

Options
i have make a simple main menu with a input field and a button:


public InputField NameField;
bool Pressed = true;

public void OnClick_ConfirmB()
{
if(NameField.text != "" && Pressed == false)
{
Pressed = true;
PhotonNetwork.playerName = NameField.text;
//SceneManager.LoadScene(1);
JoinLobby();
}
}
void OnConnectedToMaster()
{
Pressed = false;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
OnJoinedRoom();
}
}
void Awake()
{
PhotonNetwork.ConnectUsingSettings("Version 0.1");
}
void OnGUI()
{
GUI.Label(new Rect(10, 10, 100, 100), PhotonNetwork.connectionStateDetailed.ToString());
}

void JoinLobby()
{
PhotonNetwork.JoinLobby();
}
void OnJoinedLobby()
{
RoomOptions Options = new RoomOptions() { IsVisible = true, IsOpen = true};
PhotonNetwork.CreateRoom("GG", Options, TypedLobby.Default);
}

void OnJoinedRoom()
{
Debug.Log("room length : " + PhotonNetwork.GetRoomList().Length);
}


OnClick_ConfirmB() is connected to a button... the roomlist debug output is 0; i do not understand, plz help mi

Comments

  • Hi @cirex02727,

    the problem is, that your client joins a room as soon as possible. PhotonNetwork.CreateRoom(...) let the client create and join the room with just one function call. You can't create an empty room this way.

    PhotonNetwork.GetRoomList() is not working, when the client is already inside a room, it is only working as long as the client is connected to the MasterServer (is inside the lobby). So instead of creating a room in the OnJoinedLobby() callback, you would have to use PhotonNetwork.GetRoomList() there, to get an up to date room list.