Skip to main content

Function: addGridLayoutGroupComponent()

addGridLayoutGroupComponent(world, entity, options?): GridLayoutGroupEcsComponent

Defined in: ui/components/layout-group-component.ts:318

Attaches a GridLayoutGroupEcsComponent to entity, arranging every direct child that has a RectTransformEcsComponent and whose LayoutElementEcsComponent.ignoreLayout (if present) isn't true into a cell grid within the entity's own content box (its resolved rect, inset by padding). Unlike the axis groups, cell size never comes from a child's own measured size on a 'fixed' axis (the default for both columnWidthMode/rowHeightMode) - every cell on that axis is exactly cellSize. Setting either to 'content' instead derives that axis's column/row size from its cells' own measured preferred size - see UiGridLayoutGroupConstraintFields's doc comment.

Parameters​

world​

EcsWorld

The ECS world entity belongs to.

entity​

number

The entity to attach the component to. Its own RectTransformEcsComponent supplies the group's content box - add one first if entity doesn't already have one (e.g. via createPanel).

options?​

Partial<GridLayoutGroupCommonDefaultedOptions> & UiGridLayoutGroupConstraintFields = {}

Options for configuring the grid. columnWidthMode/ rowHeightMode: 'content' is only available once constraint is 'fixedColumnCount'/'fixedRowCount', enforced at compile time.

Returns​

GridLayoutGroupEcsComponent

The attached component, for further tuning or runtime changes.