OnRoomListUpdate only showing 1 room

Options

I made a multiplayer lobby so players can join a friend's room for a 1v1 game (maxplayers = 2)

Each room would appear as a button in a scroll view list if it has 1/2 players full. if a room is empty, the button will not show.


The problem when debugging is the 2nd player client instance creating a room has its button show up properly in the lobby for the first player waiting in the lobby.

However when i create a new room with a 3rd player client instance, the second room seemingly replaces the first room created (the first room disappears as if there was no player inside)


I'm using fixed Photon region with webGL, run in background


Rooms are created by players as such:


public void CreateRoom(string playerName)

  {      RoomOptions options = new RoomOptions();

      options.MaxPlayers = 2;

      options.EmptyRoomTtl = 60000;

      options.PlayerTtl = 60000;

      options.IsVisible = true;

      options.CleanupCacheOnLeave = false;

      PhotonNetwork.CreateRoom(playerName, options);

}


Then, implement RoomListUpdate:


List<RoomInfo> Rooms = new List<RoomInfo>();

public override void OnRoomListUpdate(List<RoomInfo> roomList)

  {    Rooms = roomList;

    DisplayRoomList();

    Debug.Log(roomList.Count.ToString());

  }



Room Buttons created as such:

public void DisplayRoomList() {    

foreach (Transform child in roomContent)

    {      Destroy(child.gameObject); } // destroy previous set of roomList buttons


    foreach (RoomInfo game in Rooms) {      

if (game.PlayerCount != 0) {      

   GameObject newRoom = Instantiate(roomPrefab, new Vector3(0, 0, 0), Quaternion.identity);


        MenuRoom roomScript = newRoom.GetComponent<MenuRoom>();

        roomScript.roomName = game.Name;

        roomScript.roomPlayerCount = game.PlayerCount;

        roomScript.UpdateRoomName();

        newRoom.transform.SetParent(roomContent, false);

        Debug.Log(game.Name + " room created with" + game.PlayerCount + "/" + game.MaxPlayers);

      }

    }

  }

Best Answer

Answers