private Card AddCardFromModel(ICardAssignmentModel assignment) { Card card = Instantiate(cardPrefab); card.Populate(assignment); card.AddListener((eventCard, eventType, eventData) => { switch (eventType) { case Card.EventType.POINTER_DOWN: cardManager.OnPointerDownCard(eventCard); break; case Card.EventType.POINTER_UP: cardManager.OnPointerUpCard(eventCard); break; case Card.EventType.BEGIN_DRAG: cardManager.BeginDrag(); break; default: break; } }); card.OnClick = () => onCardClicked?.Invoke(card); // Create container for the card CardContainer newContainer = Instantiate(cardContainerPrefab, transform).GetComponentInChildren <CardContainer>(); int index = this.model.GetIndexOf(card.GetCardAssignment()); newContainer.rectTransform.transform.SetSiblingIndex(index); newContainer.SetSize(CardManager.BASE_CARD_SIZE); newContainer.scaleOnFocus = false; newContainer.deck = this; newContainer.onPointerDown += () => cardManager.OnPointerDownCard(newContainer.GetCard()); newContainer.onPointerUp += (dragging) => cardManager.OnPointerUpCard(newContainer.GetCard()); newContainer.onPointerEnter += () => cardManager.OnPointerEnterContainer(newContainer); newContainer.onBeginDrag += cardManager.BeginDrag; containers.Add(newContainer); newContainer.SetCard(card); newContainer.TriggerAddEffect(); ResortCards(); return(card); }