OnRoomListUpdate

Hi,
I trying to update list of rooms but is not working. The scenario is next.
I have gameObject on scene which hold class who inherits MonoBehaviourPunCallbacks.
Class holds the method OnRoomListUpdate.

I notice that the method is not calling until the Update method is iterate all the time, why is this happening? Why is method not reacting? When is triggering method OnRoomListUpdate?
public class RoomListingMenu :  MonoBehaviourPunCallbacks

{
    [SerializeField]
    private Transform _content;

    [SerializeField]
    private RoomListing _roomListing;

    private List<RoomListing> _listings = new List<RoomListing>();

    public  override void OnRoomListUpdate(List<RoomInfo> roomList)
    {
          Debug.Log(" updatelist");
        foreach (var info in roomList)
        {
            //if (info.RemovedFromList)
            //{
            //    int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
            //    if (index != -1)
            //    {
            //        Destroy(_listings[index].gameObject);
            //        _listings.RemoveAt(index);
            //    }
            //}
            //else
            //{

                //int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);

                //if (index == -1)
                //{

                //    RoomListing listing = Instantiate(_roomListing, _content);
                //    if (listing != null)
                //    {
                //        listing.SetRoomInfo(info);
                //        _listings.Add(listing);
                //    }
                //}

                RoomListing listing = Instantiate(_roomListing, _content);
                if (listing != null)
                {
                    listing.SetRoomInfo(info);
                    _listings.Add(listing);

                }
           // }

        }
        
    }

     void Update()
    {

        
        Debug.Log("ok");
    }

    public List<RoomListing> GeRoomListings()
    {
        return _listings;
    }
}

Regards,
Nikola

Comments

  • JohnTubeJohnTube mod
    edited June 8
    Hi @Nikola,

    Thank you for choosing Photon!

    OnRoomListUpdate is called:
    - when you join a lobby of default type
    - when you are joined to a lobby of default type and the room list changes
    - when you call GetCustomRoomList which works with SQL Lobby (but does not require to join it)

    We have an example implementation of lobby rooms list handling here.
    When you extend MonoBehaviourPunCallbacks be careful when you override or implement OnEnable and OnDisable. Read more here.
  • Great, Thank you.
Sign In or Register to comment.