Room listing problem. Only list 1 room on reload

I have a unity game and i have a roomlisting script for photon PUN 2 it works like normal when i create rooms on other computers they all show up BUT when i close the game and reopen it it only shows 1 even though in the editor console it clearly says a controled amount of 6 rooms. Thats not good because when a room is created and a player starts the game right after the room was created the player wont see that open room and cant get into it. How do i fix Please.

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using System.Collections.Generic;
using UnityEngine.UI;
using TMPro;

public class RoomListDisplay : MonoBehaviourPunCallbacks
{
    public GameObject roomPrefab;
    public Transform contentPanel;

    private void Start()
    {
        // Ensure we are connected to the Photon server and in the lobby
        if (!PhotonNetwork.IsConnected)
        {
            PhotonNetwork.ConnectUsingSettings();
        }
        else
        {
            if (!PhotonNetwork.InLobby)
            {
                PhotonNetwork.JoinLobby();
            }
        }
    }

    public override void OnConnectedToMaster()
    {
        // Join the lobby when connected to the master server
        PhotonNetwork.JoinLobby();
    }

    public override void OnRoomListUpdate(List<RoomInfo> roomList)
    {
         Debug.Log("Received room list update. Total rooms: " + roomList.Count);

        // Instantiate prefabs for each room (without destroying existing ones)
        foreach (RoomInfo room in roomList)
        {
            GameObject roomEntry = Instantiate(roomPrefab, contentPanel);
            TMP_Text roomNameText = roomEntry.transform.Find("RoomNameText").GetComponent<TMP_Text>();
            TMP_Text maxPlayersText = roomEntry.transform.Find("MaxPlayersText").GetComponent<TMP_Text>();
            Button joinButton = roomEntry.transform.Find("JoinButton").GetComponent<Button>();

            roomNameText.text = "Room Name: " + room.Name; // Display the room name
            maxPlayersText.text = "Max Players: " + room.MaxPlayers;
            joinButton.onClick.AddListener(() => JoinRoom(room.Name));
        }
    }

    public void JoinRoom(string roomName)
    {
        PhotonNetwork.JoinRoom(roomName);
    }
}

9450716--1326827--Screenshot (402).png

I am not sure if you ever remove listed rooms. The updates sometimes include rooms that should no longer be listed.

Take a look at the Asteroids Demo UI. This implements the room listing properly and if you transfer that to your game, it will work.


Where is the demo ui i cant find it or i just dont know what you mean. Me and my assistant have worked A REDICULOUS AMOUNT OF WORK to try to fiqure this out . i have a few years of experience with unity but still am verry bad at coding and only know verry VERRY little. My assistant has made almost every script but this one is a little to hard we cant fiqure this out.