Exemplo n.º 1
0
    //private void Update()
    //{
    //    RebuildCard();
    //}

    public void BuildCard(UICard card)
    {
        ClearCard();
        if (card == null)
        {
            return;
        }

        if (headerLabel != null)
        {
            headerLabel.text = card.HeaderText;
        }
        isClosable = card.closable;
        if (closeButton != null)
        {
            closeButton.gameObject.SetActive(isClosable);
        }
        if (validateButton != null)
        {
            validateButton.gameObject.SetActive(isClosable && card.isEdited);
        }

        fieldInstances = new List <UIFieldBuilder>(card.FieldCount);
        float totalFieldHeight = 0;

        foreach (UIField f in card.fields)
        {
            BuildField(f, out float height);
            totalFieldHeight += height;
        }
        fieldInstancesRoot.sizeDelta = new Vector2(fieldInstancesRoot.sizeDelta.x, (1f + fieldSpacing) * totalFieldHeight);
        CurrentCard     = card;
        currentDataType = card.GetDataType().AssemblyQualifiedName;
        onCardChange.Invoke();
        AddCardListeners();
    }