Logo
Layout

Flexible Grid Layout

Responsive grid sizing with flexible rows, columns, and masonry

Overview

Flexible Grid Layout sizes a grid around its available space. It supports fixed row/column strategies, minimum cell sizes, aspect ratios, and masonry layouts.

Preview

Usage

Add Flexible Grid Layout to the parent of the items.

Choose a fit strategy in the Inspector.

Set minimum cell size, spacing, and padding.

Choose whether the layout controls child width and height.


Tips

  • Enable Preserve Aspect Ratio to keep cell proportions.
  • Fit X and Fit Y control stretching, while Masonry allows a flow that accounts for varied item sizes.
  • Avoid competing layout components on the same parent. Let Flexible Grid Layout own its children’s size and placement.

Public API

Use FlexibleGridLayout in the Evo.UI namespace.

Properties

NameTypeDescription
RowsintRequested row count.
ColumnsintRequested column count.
MinCellSizeVector2Minimum cell dimensions.
SpacingVector2Horizontal and vertical spacing.
ControlChildWidthboolLets the layout set child width.
ControlChildHeightboolLets the layout set child height.
FitXboolFits cells along the horizontal axis.
FitYboolFits cells along the vertical axis.
PreserveAspectRatioboolPreserves the configured cell ratio.
AspectRatiofloatDesired width-to-height ratio.
MasonryboolEnables masonry layout.
CellSizeVector2Read-only calculated cell dimensions.
CalculatedRowsintRead-only calculated row count.
CalculatedColumnsintRead-only calculated column count.

Fields

NameTypeDescription
fitTypeFitTypeCurrent fit strategy.

Methods

NameParametersDescription
SetFitType()FitType typeChanges the fit strategy and requests layout.

Example

FlexibleGridLayoutExample.cs
using UnityEngine;
using Evo.UI;

public class FlexibleGridLayoutExample : MonoBehaviour
{
    [SerializeField] private FlexibleGridLayout target;

    private void Start()
    {
        target.MinCellSize = new Vector2(160f, 100f);
        target.Spacing = new Vector2(12f, 12f);
        target.PreserveAspectRatio = true;
        target.AspectRatio = 1.6f;
    }
}

On this page