UIGridLayout
Positions sibling UI elements by filling rows using the space of the parent UI element.
Memory category | Instances |
---|
Member index 6
Removed member index 6
History | Member | |
---|---|---|
274 | AbsoluteSize: Vector2 | |
274 | Alignment: GridAlignment | |
274 | FillDirection: GridFillOrder | |
274 | SortOrder: GridSortOrder | |
274 | ApplyLayout(): void | |
274 | SetCustomSortFunction(function: Function): void |
Description
A UIGridLayout (not to be confused with the abstract UIGridStyleLayout from which this class inherits) lays out sibling UI elements in multiple rows within the parent UI element, adding elements to a row one-by-one until the next element would not fit. It then continues adding elements in the next row. A UIGridLayout will take UI elements' GuiObject.Size and GuiObject.Position under control. While under control, these UI elements' properties will not be editable in the Properties window.
By default, it lays out elements in ascending order where lower values take more priority over higher values, but this can be changed to use elements' names by changing UIListLayout.SortOrder to Name. A UIListLayout will automatically re-layout elements when elements are added/removed, or if a relevant property changes: GuiObject.LayoutOrder or Instance.Name. This can be triggered manually by calling UIGridStyleLayout:ApplyLayout(), though this is typically not necessary.
The actual cell sizes are the same for all cells. A UIGridLayout will respect UI constraints placed with it, such as UISizeConstraint and UIAspectRatioConstraint. Elements in the layout can span multiple cells if they have a UISizeConstraint with a MinSize set higher than the CellSize. It is possible to limit the number of elements per row using UIGridLayout.FillDirectionMaxCells. If set to 1, it is possible to create a single row of elements (as each element would be positioned in its own row).
This layout is appropriate when line breaks are OK after arbitrary cells. For example, a set of inventory spaces is a good use of this layout. If building a table of values in which a line break is not appropriate in the middle of tabular data, it might be a better idea to use a UITableLayout instead.
History 39
- 553 Change Default of StartCorner from to TopLeft
- 553 Change Default of FillDirectionMaxCells from to 0
- 553 Change Default of CellSize from to UDim2({0, 100}, {0, 100})
- 553 Change Default of CellPadding from to UDim2({0, 5}, {0, 5})
- 553 Change Default of AbsoluteCellSize from to Vector2(100, 100)
- 553 Change Default of AbsoluteCellCount from to Vector2(0, 0)
- 486 Change ThreadSafety of StartCorner from ReadOnly to ReadSafe
- 486 Change ThreadSafety of FillDirectionMaxCells from ReadOnly to ReadSafe
- 486 Change ThreadSafety of CellSize from ReadOnly to ReadSafe
- 486 Change ThreadSafety of CellPadding from ReadOnly to ReadSafe
- 462 Change ThreadSafety of StartCorner from to ReadOnly
- 462 Change ThreadSafety of FillDirectionMaxCells from to ReadOnly
- 462 Change ThreadSafety of CellSize from to ReadOnly
- 462 Change ThreadSafety of CellPadding from to ReadOnly
- 462 Change ThreadSafety of AbsoluteCellSize from to Unsafe
- 462 Change ThreadSafety of AbsoluteCellCount from to Unsafe
- 397 Change CanSave of AbsoluteCellSize from true to false
- 397 Change CanSave of AbsoluteCellCount from true to false
- 396 Add AbsoluteCellSize
- 396 Add AbsoluteCellCount
- 274 Remove SetCustomSortFunction
- 274 Remove ApplyLayout
- 274 Change ValueType of StartCorner from GridStartCorner to StartCorner
- 274 Remove SortOrder
- 274 Remove FillDirection
- 274 Remove Alignment
- 274 Remove AbsoluteSize
- 274 Change Superclass of UIGridLayout from UILayout to UIGridStyleLayout
- 266 Add SetCustomSortFunction
- 266 Add ApplyLayout
- 266 Add StartCorner
- 266 Add SortOrder
- 266 Add FillDirectionMaxCells
- 266 Add FillDirection
- 266 Add CellSize
- 266 Add CellPadding
- 266 Add Alignment
- 266 Add AbsoluteSize
- 266 Add UIGridLayout
Members 6
AbsoluteCellCount
Type | Default | |
---|---|---|
Vector2 | 0, 0 |
Measures the maximum number of elements in each direction. Read-only.
Thread safety | Unsafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 4
- 553 Change Default of AbsoluteCellCount from to Vector2(0, 0)
- 462 Change ThreadSafety of AbsoluteCellCount from to Unsafe
- 397 Change CanSave of AbsoluteCellCount from true to false
- 396 Add AbsoluteCellCount
AbsoluteCellSize
Type | Default | |
---|---|---|
Vector2 | 100, 100 |
Provides the size of each element of the grid in offsets. Read-only. Not affected by any UIScale, UISizeConstraint or UIAspectRatioConstraint applied to any individual element in the grid.
Thread safety | Unsafe |
---|---|
Category | Data |
Loaded/Saved | false |
History 4
- 553 Change Default of AbsoluteCellSize from to Vector2(100, 100)
- 462 Change ThreadSafety of AbsoluteCellSize from to Unsafe
- 397 Change CanSave of AbsoluteCellSize from true to false
- 396 Add AbsoluteCellSize
CellPadding
Type | Default | |
---|---|---|
UDim2 | {0, 5}, {0, 5} |
(default {0, 5},{0, 5}) Determines how much space there is between elements in the grid. As with all UDim2s, this space can be both in a percentage of the parent container's size and raw pixel offset.
Thread safety | ReadSafe |
---|---|
Category | Appearance |
Loaded/Saved | true |
History 4
- 553 Change Default of CellPadding from to UDim2({0, 5}, {0, 5})
- 486 Change ThreadSafety of CellPadding from ReadOnly to ReadSafe
- 462 Change ThreadSafety of CellPadding from to ReadOnly
- 266 Add CellPadding
CellSize
Type | Default | |
---|---|---|
UDim2 | {0, 100}, {0, 100} |
(default {0, 100},{0, 100}) Determines the size of each element in the grid. As with all UDim2s, this size can be both in a percentage of the parent container's size and raw pixel offset. If the element being size has a UIConstraint then the size will be determined by the constraint, not the grid.
Thread safety | ReadSafe |
---|---|
Category | Appearance |
Loaded/Saved | true |
FillDirectionMaxCells
Type | Default | |
---|---|---|
int | 0 |
FillDirectionMaxCells determines the number of cells in the grid that can be used before continuing on the next row/column (whether this is a row or column is dependent on UIGridStyleLayout.FillDirection). This value must be non-negative.
- If set to zero, there is no maximum number of cells that may appear in one row/column except for how many can fit within the parent UI element.
- If set to one, this creates a list similar to those created by UIListLayout.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of FillDirectionMaxCells from to 0
- 486 Change ThreadSafety of FillDirectionMaxCells from ReadOnly to ReadSafe
- 462 Change ThreadSafety of FillDirectionMaxCells from to ReadOnly
- 266 Add FillDirectionMaxCells
StartCorner
Type | Default | |
---|---|---|
StartCorner | TopLeft |
StartCorner (StartCorner) determines from which corner the grid starts laying out UI elements. The grid continues in the UIGridStyleLayout.FillDirection, filling elements one by one until UIGridLayout.FIllDirectionMaxCells cells have been laid out in that row/column or if all the parent UI element's space has been occupied by previous cells.
Above, the potion is the first ImageLabel, followed by the gem and the sword. The UIGridLayout is using a StartCorner of BottomRight. The UIGridStyleLayout.FillDirection is Horizontal.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 5
- 553 Change Default of StartCorner from to TopLeft
- 486 Change ThreadSafety of StartCorner from ReadOnly to ReadSafe
- 462 Change ThreadSafety of StartCorner from to ReadOnly
- 274 Change ValueType of StartCorner from GridStartCorner to StartCorner
- 266 Add StartCorner
Removed members 6
AbsoluteSize
Type | Default | |
---|---|---|
Vector2 |
Category | |
---|---|
Loaded/Saved | false |
History 2
- 274 Remove AbsoluteSize
- 266 Add AbsoluteSize
Alignment
Type | Default | |
---|---|---|
GridAlignment |
Category | |
---|---|
Loaded/Saved | false |
ApplyLayout
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
void |
History 2
- 274 Remove ApplyLayout
- 266 Add ApplyLayout
FillDirection
Type | Default | |
---|---|---|
GridFillOrder |
Category | |
---|---|
Loaded/Saved | false |
History 2
- 274 Remove FillDirection
- 266 Add FillDirection
SetCustomSortFunction
Parameters (1) | ||
---|---|---|
function | Function | |
Returns (1) | ||
void |
History 2
- 274 Remove SetCustomSortFunction
- 266 Add SetCustomSortFunction
SortOrder
Type | Default | |
---|---|---|
GridSortOrder |
Category | |
---|---|
Loaded/Saved | false |