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
-
objectObjectComponentBehaviourMonoBehaviourFlexalonCellLayout
- 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
_horizontalLayoutAlign
[SerializeField]
[Tooltip("Align the cells within the object's available size on the X axis.")]
protected Align _horizontalLayoutAlign
Field Value
_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
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
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
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
Methods
AssignCells(IFlexalonNode)
protected void AssignCells(IFlexalonNode node)
Parameters
nodeIFlexalonNode
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
previousIFlexalonNodereplacementIFlexalonNode
GetCellBounds(Vector3Int, Vector3Int, bool)
protected abstract Bounds GetCellBounds(Vector3Int cell, Vector3Int span, bool gridEdges = false)
Parameters
cellVector3IntspanVector3IntgridEdgesbool
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
columnintThe column of the cell.
rowintThe row of the cell.
layerintThe 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
columnintThe column of the cell.
rowintThe row of the cell.
layerintThe 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
columnintrowintlayerintresultsList<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
cellVector3IntThe 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
cellVector3IntresultsList<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
cellVector3IntspanVector3Int
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
cellVector3IntspanVector3IntresultsHashSet<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
columnintThe column of the cell.
rowintThe row of the cell.
layerintThe 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
cellVector3IntThe 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
columnintThe column of the cell.
rowintThe row of the cell.
layerintThe 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
columnintrowintlayerintresultsList<IFlexalonNode>
GetNodesAt(Vector3Int)
Returns the nodes of all children that start in the cell, including Flexalon Row groups.
public IFlexalonNode[] GetNodesAt(Vector3Int cell)
Parameters
cellVector3IntThe 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
cellVector3IntresultsList<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
cellVector3IntspanVector3Int
Returns
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
cellVector3IntspanVector3IntresultsHashSet<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
childGameObject
Returns
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
childGameObjectsiblingIndexint
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
childGameObjectslotFlexalonSlot
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
sourceGameObjectplaceholderGameObject
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
localPointVector3A point relative to the layout center, before transform scale and rotation.
cellVector3IntThe 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
worldPointVector3The point in world space.
cellVector3IntThe 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
columnintThe cell column.
rowintThe cell row.
boundsBoundsThe solved bounds of the cell.
layerintThe 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
cellVector3IntThe starting cell.
spanVector3IntThe number of columns, rows, and layers in the region.
boundsBoundsThe 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
columnintThe cell column.
rowintThe cell row.
boundsBoundsThe solved bounds of the grid-aligned cell region.
layerintThe 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
cellVector3IntThe starting cell.
spanVector3IntThe number of columns, rows, and layers in the region.
boundsBoundsThe 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
childIFlexalonNodeThe child node.
cellVector3IntThe child's starting cell.
spanVector3IntThe 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
childTransformThe child transform.
cellVector3IntThe child's starting cell.
spanVector3IntThe 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
queryFlexalonSlotQueryThe item, intended bounds center, and optional candidate filter.
slotFlexalonSlotThe 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
queryFlexalonSlotQueryThe item, intended bounds center, and optional candidate filter.
swapModeSwapModeNoSwap 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.
swapSlotFlexalonSlot?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.
slotFlexalonSlotThe selected slot, or default if no candidate is accepted.
swapDestinationFlexalonSlotWhere 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
queryFlexalonSlotQueryslotFlexalonSlot
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
childGameObjectslotFlexalonSlotresultFlexalonSlot
Returns
- bool