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); }