Class ScyllaUIGrid
Track-based 2D layout container. Children sit in explicit column and row tracks and may pin to a cell plus span via ScyllaUIGridItem; children without a grid item auto-flow into the next available cell, row by row.
Inheritance
Implements
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/UI/Layout/Grid")]
public sealed class ScyllaUIGrid : ScyllaUIStackBase, ILayoutElement
Remarks
The grid addresses Unity's built-in GridLayoutGroup's uniform-cell
rigidity: each track is sized independently via a
ScyllaUITrackSizingMode (Fixed, Fractional,
Auto, MinMax) so a grid can mix explicit pixel columns,
fractional fr columns, and content-driven Auto columns in the same
layout.
Inter-track spacing is configured independently per axis via ColumnGap and RowGap. Padding is inherited from the base Padding; the base Spacing property is not used on grids.
Hug sizing on either axis collapses to the sum of resolved track sizes plus gaps and padding for that axis. Auto tracks contribute the maximum preferred extent of the children assigned to that track.
Children that overflow the explicit tracks are placed into implicit rows generated by the auto-flow algorithm. Implicit rows are sized as Auto (content-driven) so overflowing children always receive a valid cell.
The two public static helpers ResolveTrackSizes(List<ScyllaUITrack>, int, float, float, float[], out float[]) and ComputeTrackOffsets(float[], float) are exposed for external tools such as editor overlays that need to mirror the grid's placement logic without running a full solve.
Properties
ColumnGap
Gap inserted between every pair of adjacent column tracks. Resolved against the grid's inner width at solve time. Setting this property marks the grid dirty and schedules a re-solve.
Declaration
public ScyllaUILength ColumnGap { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUILength |
ColumnTracks
The ordered list of column track definitions (left to right). Modify this list and call MarkDirty() to trigger a re-solve, or rebuild tracks via the ScyllaUITrack factory methods and assign a new list.
Declaration
public List<ScyllaUITrack> ColumnTracks { get; }
Property Value
| Type | Description |
|---|---|
| List<ScyllaUITrack> |
IsGrid
Always returns true for ScyllaUIGrid, signalling the solver
to dispatch to the two-pass column and row track placement path instead of the
main-axis distribution path used by H/V stacks.
Declaration
public override bool IsGrid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
IsHorizontal
Always returns true for ScyllaUIGrid. Although the grid has
no main axis in the H/V stack sense, the convention is to keep
MainContent mapped to width and CrossContent mapped to height so
the placement and hug-sizing code can read child preferred sizes using the same
fields as a horizontal stack.
Declaration
public override bool IsHorizontal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
IsZStack
Always returns false for ScyllaUIGrid. Grids do not use
depth-overlay semantics; children are placed into discrete column and row cells.
Declaration
public override bool IsZStack { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
RowGap
Gap inserted between every pair of adjacent row tracks. Resolved against the grid's inner height at solve time. Setting this property marks the grid dirty and schedules a re-solve.
Declaration
public ScyllaUILength RowGap { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUILength |
RowTracks
The ordered list of row track definitions (top to bottom). Modify this list and call MarkDirty() to trigger a re-solve, or rebuild tracks via the ScyllaUITrack factory methods and assign a new list.
Declaration
public List<ScyllaUITrack> RowTracks { get; }
Property Value
| Type | Description |
|---|---|
| List<ScyllaUITrack> |
Methods
ComputeTrackOffsets(float[], float)
Computes the leading-edge offset of every track from the origin of the grid's inner content area, given the resolved track sizes and the inter-track gap. The result is used to convert a cell column/row index into an X or Y pixel position for child placement.
Declaration
public static float[] ComputeTrackOffsets(float[] sizes, float gap)
Parameters
| Type | Name | Description |
|---|---|---|
| float[] | sizes | Resolved per-track sizes in pixels, as returned by
ResolveTrackSizes(List<ScyllaUITrack>, int, float, float, float[], out float[]). Must not be |
| float | gap | The inter-track gap in pixels. Must match the gap passed to ResolveTrackSizes(List<ScyllaUITrack>, int, float, float, float[], out float[]) for consistent results. |
Returns
| Type | Description |
|---|---|
| float[] | A newly allocated array of cumulative leading-edge offsets in pixels, one entry
per track. The array length matches |
Remarks
The offset of track i equals the sum of all preceding track sizes
plus gap * i. The first track always has offset 0.
Call ResolveTrackSizes(List<ScyllaUITrack>, int, float, float, float[], out float[]) first to obtain the sizes
array, then pass the same gap used during resolution to
keep the two arrays consistent.
ResolveTrackSizes(List<ScyllaUITrack>, int, float, float, float[], out float[])
Resolves the pixel size of every track in a column or row band against the available extent for that axis. Fixed tracks resolve their explicit length, Auto tracks take their pre-measured content extent, MinMax tracks clamp the measured content extent to their range, and Fractional tracks split the remaining space proportionally to their weight.
Declaration
public static void ResolveTrackSizes(List<ScyllaUITrack> tracks, int trackCount, float totalAvailable, float gap, float[] autoSizes, out float[] sizes)
Parameters
| Type | Name | Description |
|---|---|---|
| List<ScyllaUITrack> | tracks | The column or row track definitions to resolve. Must not be |
| int | trackCount | The total number of tracks to resolve, including any implicit tracks that lie
beyond the end of |
| float | totalAvailable | The total inner extent available for this axis, in reference-resolution pixels. Percent-based ScyllaUILength values in track definitions resolve against this value. |
| float | gap | The resolved inter-track gap in pixels. The total gap consumed is
|
| float[] | autoSizes | Per-track maximum content extents used to size |
| float[] | sizes | Outputs a newly allocated array of resolved track sizes in pixels, one entry per
track. The array length equals |
Remarks
This method is the single source of truth for track sizing. It is called by the internal layout solver and is also public so that external tools such as editor cell-guide overlays or custom hit-test code can mirror the grid's placement without running a full solve.
When autoSizes is null, Auto tracks and implicit
tracks resolve to zero. This lets callers preview the track structure before
child measurement data is available, for example when drawing a grid guide
overlay that only knows the track definitions and container size.
When trackCount exceeds the number of defined entries in
tracks, the extra indices represent implicit tracks
generated by auto-flow overflow. Implicit tracks are sized as Auto (content
extent from autoSizes) so children that spill past the
explicit grid always receive a valid cell. To resolve only the explicit
tracks, pass tracks.Count as trackCount.
The output array sizes always has at least one element;
the minimum length is 1 even when trackCount is
zero or negative.