private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); return; } _instance = this; DontDestroyOnLoad(gameObject); }
public override void OnRoomListUpdate(List <RoomInfo> roomList) { ClearRoomListView(); foreach (RoomInfo room in roomList) { // removing closed, invisible, full rooms from cachedRoomList if (!room.IsOpen || !room.IsVisible || room.RemovedFromList) { if (cachedRoomList.ContainsKey(room.Name)) { cachedRoomList.Remove(room.Name); } } else { // updating rooms that already exixts in cachedRoomList if (cachedRoomList.ContainsKey(room.Name)) { cachedRoomList[room.Name] = room; } // adding new rooms to cachedRoomList else { cachedRoomList.Add(room.Name, room); } } } foreach (RoomInfo room in cachedRoomList.Values) { GameObject roomInListGameObject = Instantiate(roomListPrefab, roomListContainer); RoomListingManager RLM = roomInListGameObject.GetComponent <RoomListingManager>(); RLM.roomNameText.text = room.Name; RLM.roomCapacityText.text = room.PlayerCount + " / " + room.MaxPlayers; RLM.joinButton.onClick.AddListener(() => OnJoinRoomButtonClicked(room.Name)); roomListGameObjects.Add(room.Name, roomInListGameObject); } }