Exemplo n.º 1
0
    public override void OnRoomListUpdate(List <RoomInfo> roomList)
    {
        foreach (RoomInfo info in roomList)
        {
            int index = listings.FindIndex(x => x.RoomInfo.Name == info.Name);

            if (info.RemovedFromList)
            {
                if (index != -1)
                {
                    Destroy(listings[index].gameObject);
                    listings.RemoveAt(index);
                }
            }
            else
            {
                if (index == -1)
                {
                    RoomListing listing = Instantiate(_roomListing, _content);
                    if (listing != null)
                    {
                        listing.setRoomInfo(info);
                        listings.Add(listing);
                    }
                }
            }
        }
    }