Table of Contents

Class FlexalonCellLayout

Namespace
Flexalon
Assembly
Flexalon.dll

Base class for Grid and Table layouts, which place children in cells. Provides queries to find cells, their bounds, and the children in them.

public abstract class FlexalonCellLayout : FlexalonLayoutBase, IFlexalonLayout, IFlexalonSlottedLayout
Inheritance
object
Object
Component
Behaviour
MonoBehaviour
FlexalonCellLayout
Implements
Derived
Inherited Members

Fields

_cellCounts

[SerializeField]
[HideInInspector]
protected Vector3Int _cellCounts

Field Value

Vector3Int

_depthLayoutAlign

[SerializeField]
[Tooltip("Align the cells within the object's available size on the Z axis.")]
protected Align _depthLayoutAlign

Field Value

Align

_horizontalLayoutAlign

[SerializeField]
[Tooltip("Align the cells within the object's available size on the X axis.")]
protected Align _horizontalLayoutAlign

Field Value

Align

_useLayers

[SerializeField]
[Tooltip("Whether to place children across multiple layers.")]
protected bool _useLayers

Field Value

bool

_verticalLayoutAlign

[SerializeField]
[Tooltip("Align the cells within the object's available size on the Y axis.")]
protected Align _verticalLayoutAlign

Field Value

Align

Properties

DepthLayoutAlign

How the cells are aligned on the Z axis when the layout has extra space, inside its padding.

public Align DepthLayoutAlign { get; set; }

Property Value

Align

HorizontalLayoutAlign

How the cells are aligned on the X axis when the layout has extra space, inside its padding.

public Align HorizontalLayoutAlign { get; set; }

Property Value

Align

MinCellCount

protected abstract Vector3Int MinCellCount { get; }

Property Value

Vector3Int

UseLayers

Whether to place children across multiple layers.

public bool UseLayers { get; set; }

Property Value

bool

VerticalLayoutAlign

How the cells are aligned on the Y axis when the layout has extra space, inside its padding.

public Align VerticalLayoutAlign { get; set; }

Property Value

Align

Methods

AssignCells(IFlexalonNode)

protected void AssignCells(IFlexalonNode node)

Parameters

node IFlexalonNode

EnsureCellLookup()

protected void EnsureCellLookup()

FastSwapChild(IFlexalonNode, IFlexalonNode)

Updates cached child references after a trusted swap. Both nodes already occupy their new slots. A same-parent exchange invokes this notification once; other swaps invoke each affected layout. The previous child is detached when the replacement was detached. Override when retaining child references between layout passes. This notification does not validate compatibility or request a new layout pass.

public override void FastSwapChild(IFlexalonNode previous, IFlexalonNode replacement)

Parameters

previous IFlexalonNode
replacement IFlexalonNode

GetCellBounds(Vector3Int, Vector3Int, bool)

protected abstract Bounds GetCellBounds(Vector3Int cell, Vector3Int span, bool gridEdges = false)

Parameters

cell Vector3Int
span Vector3Int
gridEdges bool

Returns

Bounds

GetChildAt(int, int, int)

Returns the first child that starts in the cell, or null if there is none. Flexalon Row groups are skipped, and children without a GameObject return null.

public Transform GetChildAt(int column, int row, int layer = 0)

Parameters

column int

The column of the cell.

row int

The row of the cell.

layer int

The layer of the cell.

Returns

Transform

The first child transform starting in the cell.

GetChildrenAt(int, int, int)

Returns all children that start in the cell, including Flexalon Row groups. Children without a GameObject are skipped.

public Transform[] GetChildrenAt(int column, int row, int layer = 0)

Parameters

column int

The column of the cell.

row int

The row of the cell.

layer int

The layer of the cell.

Returns

Transform[]

A list of child transforms in the cell.

GetChildrenAt(int, int, int, List<Transform>)

Clears and fills results with the same children as GetChildrenAt, without allocating an array.

public void GetChildrenAt(int column, int row, int layer, List<Transform> results)

Parameters

column int
row int
layer int
results List<Transform>

GetChildrenAt(Vector3Int)

Returns all children that start in the cell, including Flexalon Row groups. Children without a GameObject are skipped.

public Transform[] GetChildrenAt(Vector3Int cell)

Parameters

cell Vector3Int

The column, row, and layer of the cell.

Returns

Transform[]

A list of child transforms in the cell.

GetChildrenAt(Vector3Int, List<Transform>)

Clears and fills results with the same children as GetChildrenAt, without allocating an array.

public void GetChildrenAt(Vector3Int cell, List<Transform> results)

Parameters

cell Vector3Int
results List<Transform>

GetChildrenInSpan(Vector3Int, Vector3Int)

Returns every child that occupies at least one cell in the region, including children that start outside it, Flexalon Row groups, and the children of those groups. Children without a GameObject are skipped. The results are in no particular order.

public Transform[] GetChildrenInSpan(Vector3Int cell, Vector3Int span)

Parameters

cell Vector3Int
span Vector3Int

Returns

Transform[]

GetChildrenInSpan(Vector3Int, Vector3Int, HashSet<Transform>)

Clears and fills results with the same children as GetChildrenInSpan, without allocating an array. The results are in no particular order.

public void GetChildrenInSpan(Vector3Int cell, Vector3Int span, HashSet<Transform> results)

Parameters

cell Vector3Int
span Vector3Int
results HashSet<Transform>

GetLayoutOffset()

protected abstract Vector3 GetLayoutOffset()

Returns

Vector3

GetNodeAt(int, int, int)

Returns the node of the first child that starts in the cell, or null if there is none. Flexalon Row groups are skipped.

public IFlexalonNode GetNodeAt(int column, int row, int layer = 0)

Parameters

column int

The column of the cell.

row int

The row of the cell.

layer int

The layer of the cell.

Returns

IFlexalonNode

The first child node starting in the cell.

GetNodeAt(Vector3Int)

Returns the node of the first child that starts in the cell, or null if there is none. Flexalon Row groups are skipped.

public IFlexalonNode GetNodeAt(Vector3Int cell)

Parameters

cell Vector3Int

The column, row, and layer of the cell.

Returns

IFlexalonNode

The first child node starting in the cell.

GetNodesAt(int, int, int)

Returns the nodes of all children that start in the cell, including Flexalon Row groups.

public IFlexalonNode[] GetNodesAt(int column, int row, int layer = 0)

Parameters

column int

The column of the cell.

row int

The row of the cell.

layer int

The layer of the cell.

Returns

IFlexalonNode[]

A list of child nodes in the cell.

GetNodesAt(int, int, int, List<IFlexalonNode>)

Clears and fills results with the same nodes as GetNodesAt, without allocating an array.

public void GetNodesAt(int column, int row, int layer, List<IFlexalonNode> results)

Parameters

column int
row int
layer int
results List<IFlexalonNode>

GetNodesAt(Vector3Int)

Returns the nodes of all children that start in the cell, including Flexalon Row groups.

public IFlexalonNode[] GetNodesAt(Vector3Int cell)

Parameters

cell Vector3Int

The column, row, and layer of the cell.

Returns

IFlexalonNode[]

A list of child nodes in the cell.

GetNodesAt(Vector3Int, List<IFlexalonNode>)

Clears and fills results with the same nodes as GetNodesAt, without allocating an array.

public void GetNodesAt(Vector3Int cell, List<IFlexalonNode> results)

Parameters

cell Vector3Int
results List<IFlexalonNode>

GetNodesInSpan(Vector3Int, Vector3Int)

Returns the node of every child that occupies at least one cell in the region, including children that start outside it, children without a GameObject, Flexalon Row groups, and the children of those groups. The results are in no particular order.

public IFlexalonNode[] GetNodesInSpan(Vector3Int cell, Vector3Int span)

Parameters

cell Vector3Int
span Vector3Int

Returns

IFlexalonNode[]

GetNodesInSpan(Vector3Int, Vector3Int, HashSet<IFlexalonNode>)

Clears and fills results with the same nodes as GetNodesInSpan, without allocating an array. The results are in no particular order.

public void GetNodesInSpan(Vector3Int cell, Vector3Int span, HashSet<IFlexalonNode> results)

Parameters

cell Vector3Int
span Vector3Int
results HashSet<IFlexalonNode>

GetSlot(GameObject)

Captures the object's current resolved slot, or null if it has no placement in this layout.

public FlexalonSlot? GetSlot(GameObject child)

Parameters

child GameObject

Returns

FlexalonSlot?

GetSolvedCellCounts()

Returns the column, row, and layer counts from the most recent layout update, including tracks generated by child placement and spans. Collection Count properties specify explicit tracks; the solved layer count is one when layers are disabled.

public Vector3Int GetSolvedCellCounts()

Returns

Vector3Int

PlaceInOrder(GameObject, int)

Parents the object to this layout at the supplied sibling index and configures it for placement in hierarchy order. Cell layouts clear explicit placement while preserving the cell component's enabled state, span, and overlap settings.

public void PlaceInOrder(GameObject child, int siblingIndex)

Parameters

child GameObject
siblingIndex int

PlaceInSlot(GameObject, in FlexalonSlot)

Parents the object to this layout and applies a slot belonging to it without searching or checking occupancy. Implementations establish the sibling order required for slot placement. Cell layouts enable explicit placement, preserve span and overlap settings, and use sibling index zero to give the object placement priority.

public void PlaceInSlot(GameObject child, in FlexalonSlot slot)

Parameters

child GameObject
slot FlexalonSlot

PreparePlaceholder(GameObject, GameObject)

Copies the dragged object's layout-specific options to a placeholder without changing the source. May be called again when the selected placement changes.

public void PreparePlaceholder(GameObject source, GameObject placeholder)

Parameters

source GameObject
placeholder GameObject

TryGetCellAtLocalPoint(Vector3, out Vector3Int)

Finds the cell containing a point in the same layout space as TryGetCellBounds. Gaps belong to the nearest track; shared boundaries choose the lower track index.

public abstract bool TryGetCellAtLocalPoint(Vector3 localPoint, out Vector3Int cell)

Parameters

localPoint Vector3

A point relative to the layout center, before transform scale and rotation.

cell Vector3Int

The column, row, and layer containing the point.

Returns

bool

True if the point is inside the solved grid, including its depth.

TryGetCellAtWorldPoint(Vector3, out Vector3Int)

Finds the cell containing a world point, using the same gap coverage as the local query.

public bool TryGetCellAtWorldPoint(Vector3 worldPoint, out Vector3Int cell)

Parameters

worldPoint Vector3

The point in world space.

cell Vector3Int

The column, row, and layer containing the point.

Returns

bool

True if the point is inside the solved grid.

TryGetCellBounds(int, int, out Bounds, int)

Attempts to get a cell's layout-space bounds, excluding surrounding gaps.

public bool TryGetCellBounds(int column, int row, out Bounds bounds, int layer = 0)

Parameters

column int

The cell column.

row int

The cell row.

bounds Bounds

The solved bounds of the cell.

layer int

The cell layer.

Returns

bool

True if bounds are available.

TryGetCellBounds(Vector3Int, Vector3Int, out Bounds)

Gets layout-space bounds, including gaps inside the span but excluding surrounding gaps, without measuring.

public bool TryGetCellBounds(Vector3Int cell, Vector3Int span, out Bounds bounds)

Parameters

cell Vector3Int

The starting cell.

span Vector3Int

The number of columns, rows, and layers in the region.

bounds Bounds

The solved bounds of the region.

Returns

bool

True if bounds are available.

TryGetCellGridBounds(int, int, out Bounds, int)

Attempts to get a cell's layout-space bounds extending to the midpoint of surrounding gaps.

public bool TryGetCellGridBounds(int column, int row, out Bounds bounds, int layer = 0)

Parameters

column int

The cell column.

row int

The cell row.

bounds Bounds

The solved bounds of the grid-aligned cell region.

layer int

The cell layer.

Returns

bool

True if bounds are available.

TryGetCellGridBounds(Vector3Int, Vector3Int, out Bounds)

Gets layout-space bounds extending to surrounding gap midpoints, without measuring. Outer table edges are not extended.

public bool TryGetCellGridBounds(Vector3Int cell, Vector3Int span, out Bounds bounds)

Parameters

cell Vector3Int

The starting cell.

span Vector3Int

The number of columns, rows, and layers in the region.

bounds Bounds

The solved bounds of the grid-aligned region.

Returns

bool

True if bounds are available.

TryGetChildCell(IFlexalonNode, out Vector3Int, out Vector3Int)

Attempts to get the solved cell and span of a child node in the table.

public bool TryGetChildCell(IFlexalonNode child, out Vector3Int cell, out Vector3Int span)

Parameters

child IFlexalonNode

The child node.

cell Vector3Int

The child's starting cell.

span Vector3Int

The number of columns, rows, and layers occupied by the child.

Returns

bool

True if the child is part of the solved table layout.

TryGetChildCell(Transform, out Vector3Int, out Vector3Int)

Attempts to get the solved cell and span of a child in the table.

public bool TryGetChildCell(Transform child, out Vector3Int cell, out Vector3Int span)

Parameters

child Transform

The child transform.

cell Vector3Int

The child's starting cell.

span Vector3Int

The number of columns, rows, and layers occupied by the child.

Returns

bool

True if the child is part of the solved table layout.

TryGetFirstOpenSlot(in FlexalonSlotQuery, out FlexalonSlot)

Finds the first fitting open span in layout order. Does not require overlap with the item bounds.

public bool TryGetFirstOpenSlot(in FlexalonSlotQuery query, out FlexalonSlot slot)

Parameters

query FlexalonSlotQuery

The item, intended bounds center, and optional candidate filter.

slot FlexalonSlot

The selected slot, or default if no candidate is accepted.

Returns

bool

TryGetNearestOpenSlot(in FlexalonSlotQuery, SwapMode, in FlexalonSlot?, out FlexalonSlot, out FlexalonSlot)

Finds the nearest fitting open slot near the item center. Cell layouts also check immediate neighboring placements for multi-cell items.

public bool TryGetNearestOpenSlot(in FlexalonSlotQuery query, SwapMode swapMode, in FlexalonSlot? swapSlot, out FlexalonSlot slot, out FlexalonSlot swapDestination)

Parameters

query FlexalonSlotQuery

The item, intended bounds center, and optional candidate filter.

swapMode SwapMode

NoSwap requires an open candidate. AllowSwap also accepts a candidate with one eligible occupant, reported in the slot's SwapNode. RequireSwap only accepts candidates with an occupant. The query does not move or exchange objects.

swapSlot FlexalonSlot?

Optional slot the occupant would move to, such as the dragged item's starting slot. When set, candidates are rejected unless TryGetSwapSlot finds a placement for the occupant there that does not overlap the candidate.

slot FlexalonSlot

The selected slot, or default if no candidate is accepted.

swapDestination FlexalonSlot

Where the selected slot's occupant would move, or default if the slot has no occupant or no swapSlot was given.

Returns

bool

TryGetNearestSlot(in FlexalonSlotQuery, out FlexalonSlot)

Finds a fitting slot near the item center, using the layout's candidate and occupancy rules.

public bool TryGetNearestSlot(in FlexalonSlotQuery query, out FlexalonSlot slot)

Parameters

query FlexalonSlotQuery
slot FlexalonSlot

Returns

bool

TryGetSwapSlot(GameObject, in FlexalonSlot, out FlexalonSlot)

Finds a placement for the item that covers this slot, preferring the slot itself and otherwise the fitting placement nearest to it, so an item larger than the slot can shift to fit. Does not move the item. Cell layouts require containment within the solved layout and delegated row, ignore the item's existing placement and nonblocking overlaps, and check only top-level blockers when placing a whole row. Returns false for a slot owned by another layout or unavailable layout geometry.

public bool TryGetSwapSlot(GameObject child, in FlexalonSlot slot, out FlexalonSlot result)

Parameters

child GameObject
slot FlexalonSlot
result FlexalonSlot

Returns

bool