Exemple #1
0
    public override void SetLayoutVertical()
    {
        if (rectChildren.Count == 0 || rows == 0)
        {
            return;
        }

        float height = (rectTransform.rect.height - padding.vertical - spacing.y * (rows - 1)) / (float)rows;

        for (int i = 0; i < rectChildren.Count; i++)
        {
            float             y    = padding.top + (height + spacing.y) * (i / columns);
            CellLayoutElement cell = rectChildren[i].gameObject.GetComponent <CellLayoutElement>();
            if (cell == null)
            {
                SetChildAlongAxis(rectChildren[i], 1, y, height);
            }
            else
            {
                SetChildAlongAxis(rectChildren[i], 1, y + height * cell.offset.y, height * cell.sizeScale.y);
            }
        }
    }
Exemple #2
0
    public override void SetLayoutHorizontal()
    {
        if (rectChildren.Count == 0 || columns == 0)
        {
            return;
        }

        float width = (rectTransform.rect.width - padding.horizontal - spacing.x * (columns - 1)) / (float)columns;

        for (int i = 0; i < rectChildren.Count; i++)
        {
            float             x    = padding.left + (width + spacing.x) * (i % columns);
            CellLayoutElement cell = rectChildren[i].gameObject.GetComponent <CellLayoutElement>();
            if (cell == null)
            {
                SetChildAlongAxis(rectChildren[i], 0, x, width);
            }
            else
            {
                SetChildAlongAxis(rectChildren[i], 0, x + width * cell.offset.x, width * cell.sizeScale.x);
            }
        }
    }