Class GridLayoutGroup
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
[AddComponentMenu("Layout/Grid Layout Group", 152)]
public class GridLayoutGroup : LayoutGroup, ILayoutElement, ILayoutGroup, ILayoutController
Constructors
GridLayoutGroup()
Declaration
protected GridLayoutGroup()
Fields
m_CellSize
Declaration
[SerializeField]
protected Vector2 m_CellSize
Field Value
Type | Description |
---|---|
Vector2 |
m_Constraint
Declaration
[SerializeField]
protected GridLayoutGroup.Constraint m_Constraint
Field Value
Type | Description |
---|---|
GridLayoutGroup.Constraint |
m_ConstraintCount
Declaration
[SerializeField]
protected int m_ConstraintCount
Field Value
Type | Description |
---|---|
int |
m_Spacing
Declaration
[SerializeField]
protected Vector2 m_Spacing
Field Value
Type | Description |
---|---|
Vector2 |
m_StartAxis
Declaration
[SerializeField]
protected GridLayoutGroup.Axis m_StartAxis
Field Value
Type | Description |
---|---|
GridLayoutGroup.Axis |
m_StartCorner
Declaration
[SerializeField]
protected GridLayoutGroup.Corner m_StartCorner
Field Value
Type | Description |
---|---|
GridLayoutGroup.Corner |
Properties
cellSize
The size to use for each cell in the grid.
Declaration
public Vector2 cellSize { get; set; }
Property Value
Type | Description |
---|---|
Vector2 |
constraint
Which constraint to use for the GridLayoutGroup.
Declaration
public GridLayoutGroup.Constraint constraint { get; set; }
Property Value
Type | Description |
---|---|
GridLayoutGroup.Constraint |
Remarks
Specifying a constraint can make the GridLayoutGroup work better in conjunction with a [[ContentSizeFitter]] component. When GridLayoutGroup is used on a RectTransform with a manually specified size, there's no need to specify a constraint.
constraintCount
How many cells there should be along the constrained axis.
Declaration
public int constraintCount { get; set; }
Property Value
Type | Description |
---|---|
int |
spacing
The spacing to use between layout elements in the grid on both axises.
Declaration
public Vector2 spacing { get; set; }
Property Value
Type | Description |
---|---|
Vector2 |
startAxis
Which axis should cells be placed along first
Declaration
public GridLayoutGroup.Axis startAxis { get; set; }
Property Value
Type | Description |
---|---|
GridLayoutGroup.Axis |
Remarks
When startAxis is set to horizontal, an entire row will be filled out before proceeding to the next row. When set to vertical, an entire column will be filled out before proceeding to the next column.
startCorner
Which corner should the first cell be placed in?
Declaration
public GridLayoutGroup.Corner startCorner { get; set; }
Property Value
Type | Description |
---|---|
GridLayoutGroup.Corner |
Methods
CalculateLayoutInputHorizontal()
Called by the layout system to calculate the horizontal layout size. Also see ILayoutElement
Declaration
public override void CalculateLayoutInputHorizontal()
Overrides
CalculateLayoutInputVertical()
Called by the layout system to calculate the vertical layout size. Also see ILayoutElement
Declaration
public override void CalculateLayoutInputVertical()
Overrides
OnValidate()
Declaration
protected override void OnValidate()
Overrides
SetLayoutHorizontal()
Called by the layout system Also see ILayoutElement
Declaration
public override void SetLayoutHorizontal()
Overrides
SetLayoutVertical()
Called by the layout system Also see ILayoutElement
Declaration
public override void SetLayoutVertical()