List Rooms (PUN2)

Options
Hi guys , I need to list the romos in my lobby scene. For now, this is the code I've used but I don't know why it isnt working. This is the correct way?
  public override void OnRoomListUpdate(List<RoomInfo> roomList)
     {
         print(roomList.Count + " Rooms");
         base.OnRoomListUpdate(roomList);
         foreach (var Item in roomList)
         {
             RoomName = Item.Name;
             PlayerAmount = Item.PlayerCount;
             MaxPlayers = Item.MaxPlayers;
             PhotonNetwork.Instantiate("RoomPrefab", transform.position, transform.rotation);
             RoomPrefab.transform.Find("RoomName").GetComponent<Text>().text = RoomName;
             RoomPrefab.transform.Find("PlayerInt").GetComponent<Text>().text = PlayerAmount.ToString();
             if(MaxPlayers == 4)
             {
                 GameObject.Find("IPlayerA").GetComponent<Image>().sprite = Four;
             }
             else if (MaxPlayers == 2)
             {
                 GameObject.Find("IPlayerA").GetComponent<Image>().sprite = Two;
             }
             else if (MaxPlayers == 3)
             {
                 GameObject.Find("IPlayerA").GetComponent<Image>().sprite = Three;
             }
             RoomPrefab.transform.SetParent(ScrollView.transform, false);
         }
     }

Comments

  • RogerRam
    Options
    same to me, it just happen in the Unity editor, once you have a build works fine, but we need it in the editor anyway for debugging.
  • RogerRam
    Options
    your code is not bad, but check the Asteriods example the cachedRoomList function that helps to keep an updated room list all the time.
  • SebGM2018
    Options
    RogerRam said:

    your code is not bad, but check the Asteriods example the cachedRoomList function that helps to keep an updated room list all the time.

    Can you please share your code to me? That would be very helpful because there's nothing of info of PUN2.



    Also, since yesterday PUN can't connect to rooms even if I create one and select to join a random room and it was working very well...
    Thanks.