using Photon.Pun; using Photon.Realtime; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AdminLobby : MonoBehaviourPunCallbacks, ILobbyCallbacks { public GameObject listItemPrefab; public Transform parent; public static AdminLobby instance; void Awake() { if(instance != null) { Destroy(gameObject); return; } instance = this; DontDestroyOnLoad(gameObject); PhotonNetwork.Disconnect(); PhotonNetwork.ConnectUsingSettings(); } public override void OnConnectedToMaster() { base.OnConnectedToMaster(); Debug.Log("Connected to photon"); PhotonNetwork.JoinLobby(); } // Update is called once per frame void Update() { } public override void OnRoomListUpdate(List roomList) { base.OnRoomListUpdate(roomList); //PURGE foreach(Transform child in parent.GetComponentsInChildren()) { if(child == parent) { continue; } Destroy(child.gameObject); } RoomInfo _room; foreach(RoomInfo room in roomList) { GameObject newItem = Instantiate(listItemPrefab, parent); _room = room; newItem.GetComponentInChildren().text = room.Name; newItem.GetComponentInChildren