Hello, script that should create room list (I want to show list of room, so Players can See rooms that actually exists and join it) doesn’t work from some reason… I was trying to fix it for some time, but still I can’t get why it’s not working. I guess that OnRoomListUpdata() is not called, but why?
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace MyProject
{
public class RoomListingDisplay : MonoBehaviourPunCallbacks
{
[SerializeField]
private Transform _content; // ScrollView/ViewPort/Content
[SerializeField]
private RoomListing _roomListing;
private List<RoomListing> _listings = new List<RoomListing>();
public override void OnJoinedRoom()
{
_listings.Clear();
}
public override void OnRoomListUpdate(List<RoomInfo> roomList)
{
foreach (RoomInfo info in roomList)
{
print(info.Name);
//Removed from rooms list.
if (info.RemovedFromList)
{
int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
if (index != -1)
{
Destroy(_listings[index].gameObject);
_listings.RemoveAt(index);
}
}
//Added to rooms list.
else
{
int index = _listings.FindIndex(x => x.RoomInfo.Name == info.Name);
if (index == -1)
{
RoomListing listing = Instantiate(_roomListing, _content);
print("Instantiated");
if (listing != null)
{
listing.SetRoomInfo(info);
_listings.Add(listing);
}
}
else
{
}
}
}
}
}
}