Example #1
0
        void GroupUIElements()
        {
            uiElementsGroup.Clear();

            var base_length = Stacking == Stackings.Horizontal ? rectTransform.rect.width : rectTransform.rect.height;

            base_length -= (Stacking == Stackings.Horizontal) ? (GetMarginLeft() + GetMarginRight()) : (GetMarginTop() + GetMarginBottom());

            var ui_elements = GetUIElements();

            if (LayoutType == LayoutTypes.Compact)
            {
                EasyLayoutCompact.Group(ui_elements, base_length, this, uiElementsGroup);
            }
            else
            {
                EasyLayoutGrid.Group(ui_elements, base_length, this, uiElementsGroup);
            }

            if (!TopToBottom)
            {
                uiElementsGroup.Reverse();
            }

            if (RightToLeft)
            {
                uiElementsGroup.ForEach(ReverseList);
            }

            CalculateSize();

            Resizer.ResizeGroup(uiElementsGroup);

            foreach (var block in uiElementsGroup.ToArray())
            {
                block.ForEach(x => x.ApplyResize());
            }
        }
Example #2
0
        List <List <RectTransform> > GroupUIElements()
        {
            var base_length = GetLength(rectTransform, false);

            base_length -= (Stacking == Stackings.Horizontal) ? (GetMarginLeft() + GetMarginRight()) : (GetMarginTop() + GetMarginBottom());

            var ui_elements = GetUIElements();

            var group = (LayoutType == LayoutTypes.Compact)
                                ? EasyLayoutCompact.Group(ui_elements, base_length, this)
                                : EasyLayoutGrid.Group(ui_elements, base_length, this);

            if (Stacking == Stackings.Vertical)
            {
                group = Transpose(group);
            }

            if (!TopToBottom)
            {
                group.Reverse();
            }

            if (RightToLeft)
            {
                group.ForEach(ReverseList);
            }

            var width  = rectTransform.rect.width - (GetMarginLeft() + GetMarginRight());
            var height = rectTransform.rect.height - (GetMarginTop() + GetMarginBottom());

            if (LayoutType == LayoutTypes.Grid)
            {
                if (ChildrenWidth == ChildrenSize.FitContainer)
                {
                    ResizeColumnWidthToFit(width, group);
                }
                if (ChildrenHeight == ChildrenSize.FitContainer)
                {
                    ResizeRowHeightToFit(height, group);
                }
            }
            else
            {
                if (Stacking == Stackings.Horizontal)
                {
                    if (ChildrenWidth == ChildrenSize.FitContainer)
                    {
                        ResizeWidthToFit(width, group);
                    }
                    if (ChildrenHeight == ChildrenSize.FitContainer)
                    {
                        ResizeRowHeightToFit(height, group);
                    }
                }
                else
                {
                    if (ChildrenHeight == ChildrenSize.FitContainer)
                    {
                        ResizeHeightToFit(height, group);
                    }
                    if (ChildrenWidth == ChildrenSize.FitContainer)
                    {
                        ResizeColumnWidthToFit(width, group);
                    }
                }
            }

            return(group);
        }
Example #3
0
        List <List <RectTransform> > GroupUIElements()
        {
            var base_length = GetLength(rectTransform, false);

            base_length -= (Stacking == Stackings.Horizontal) ? (GetMarginLeft() + GetMarginRight()) : (GetMarginTop() + GetMarginBottom());

            var ui_elements = GetUIElements();

            ClearUIElementsGroup();
            if (LayoutType == LayoutTypes.Compact)
            {
                EasyLayoutCompact.Group(ui_elements, base_length, this, uiElementsGroup);

                if (Stacking == Stackings.Vertical)
                {
                    uiElementsGroup = EasyLayoutUtilites.Transpose(uiElementsGroup);
                }
            }
            else
            {
                GridConstraintCount = Mathf.Max(1, GridConstraintCount);
                if (GridConstraint == GridConstraints.Flexible)
                {
                    EasyLayoutGrid.GroupFlexible(ui_elements, base_length, this, uiElementsGroup);
                }
                else if (GridConstraint == GridConstraints.FixedRowCount)
                {
                    if (Stacking == Stackings.Vertical)
                    {
                        EasyLayoutGrid.GroupByRowsVertical(ui_elements, this, GridConstraintCount, uiElementsGroup);
                    }
                    else
                    {
                        EasyLayoutGrid.GroupByRowsHorizontal(ui_elements, this, GridConstraintCount, uiElementsGroup);
                    }
                }
                else if (GridConstraint == GridConstraints.FixedColumnCount)
                {
                    if (Stacking == Stackings.Vertical)
                    {
                        EasyLayoutGrid.GroupByColumnsVertical(ui_elements, this, GridConstraintCount, uiElementsGroup);
                    }
                    else
                    {
                        EasyLayoutGrid.GroupByColumnsHorizontal(ui_elements, this, GridConstraintCount, uiElementsGroup);
                    }
                }
            }

            if (!TopToBottom)
            {
                uiElementsGroup.Reverse();
            }

            if (RightToLeft)
            {
                uiElementsGroup.ForEach(ReverseList);
            }

            var width  = rectTransform.rect.width - (GetMarginLeft() + GetMarginRight());
            var height = rectTransform.rect.height - (GetMarginTop() + GetMarginBottom());

            if (LayoutType == LayoutTypes.Grid)
            {
                if (ChildrenWidth == ChildrenSize.FitContainer)
                {
                    EasyLayoutUtilites.ResizeColumnWidthToFit(width, uiElementsGroup, Spacing.x, PaddingInner.Left + PaddingInner.Right);
                }
                if (ChildrenHeight == ChildrenSize.FitContainer)
                {
                    EasyLayoutUtilites.ResizeRowHeightToFit(height, uiElementsGroup, Spacing.y, PaddingInner.Top + PaddingInner.Bottom);
                }
            }
            else
            {
                if (Stacking == Stackings.Horizontal)
                {
                    if (ChildrenWidth == ChildrenSize.FitContainer)
                    {
                        EasyLayoutUtilites.ResizeWidthToFit(width, uiElementsGroup, Spacing.x);
                    }
                    if (ChildrenHeight == ChildrenSize.FitContainer)
                    {
                        EasyLayoutUtilites.ResizeRowHeightToFit(height, uiElementsGroup, Spacing.y, PaddingInner.Top + PaddingInner.Bottom);
                    }
                }
                else
                {
                    if (ChildrenHeight == ChildrenSize.FitContainer)
                    {
                        EasyLayoutUtilites.ResizeHeightToFit(height, uiElementsGroup, Spacing.y);
                    }
                    if (ChildrenWidth == ChildrenSize.FitContainer)
                    {
                        EasyLayoutUtilites.ResizeColumnWidthToFit(width, uiElementsGroup, Spacing.x, PaddingInner.Left + PaddingInner.Right);
                    }
                }
            }

            return(uiElementsGroup);
        }