GridLayoutTag

grid

Description

A grid container

Components and Properties

Backgroundable

bg

background

background string

The background of this backgroundable.

bg-alpha

background-alpha

float

The opacity of the background.

bg-color

background-color

color string

The color of this background.

bg-color0

background-color0

color string

The first color of the gradient.

bg-color1

background-color1

color string

The second color of the gradient.

ContentSizeFitter

horizontal-fit

FitMode

How the width is controlled.

vertical-fit

FitMode

How the height is controlled.

GridLayoutGroup

cell-size

Vector2

The size to use for each cell in the grid.

cell-size-x

float

Width of each cell in the grid.

cell-size-y

float

Height of each cell in the grid.

spacing

Vector2

The spacing to use between layout elements in the grid.

spacing-x

float

Horizontal space between cells.

spacing-y

float

Vertical space between cells.

LayoutGroup

child-alignment

child-align

TextAnchor

The alignment to use for the child layout elements in the layout group.

padding

pad

int

Padding for all directions.

pad-bottom

int

Bottom padding.

pad-left

int

Left padding.

pad-right

int

Right padding.

pad-top

int

Top padding.

RectTransform

active

bool

Whether or not the GameObject this RectTransform belongs to is active.

anchor-max

Vector2

The anchor point for the upper right corner of the rectangle defined as a fraction of the size of the parent rectangle.

anchor-max-x

float

The normalized x position in the parent RectTransform that the upper right corner is anchored to.

anchor-max-y

float

The normalized y position in the parent RectTransform that the upper right corner is anchored to.

anchor-min

Vector2

The anchor point for the lower left corner of the rectangle defined as a fraction of the size of the parent rectangle.

anchor-min-x

float

The normalized x position in the parent RectTransform that the lower left corner is anchored to.

anchor-min-y

float

The normalized y position in the parent RectTransform that the lower left corner is anchored to.

anchored-position

Vector2

Position of the rectangle’s pivot point relative to the anchors.

anchored-position-x

anchor-pos-x

float

The x position of the pivot of this RectTransform relative to the anchor reference point.

anchored-position-y

anchor-pos-y

float

The y position of the pivot of this RectTransform relative to the anchor reference point.

hover-hint

string

Text that will appear when a pointer hovers over.

hover-hint-key

localization key

The localization key used for the hover hint text.

local-scale

scale

Vector3

Scale factor applied to the object in the X, Y and Z dimensions.

name

string

The name of the GameObject.

pivot

Vector2

The location around which the rectangle rotates.

pivot-x

float

Normalized x position to rotate around.

pivot-y

float

Normalized y position to rotate around.

size-delta

Vector2

The size added to the rectangle defined by the anchors.

size-delta-x

float

The width added to the rectangle defined by the anchors.

size-delta-y

float

The height added to the rectangle defined by the anchors.

Example Usage

example.bsml

<vertical child-control-height="false">
  <horizontal bg="panel-top" pad-left="15" pad-right="15" horizontal-fit="PreferredSize">
    <text text="Grid" align="Center" font-size="8"/>
  </horizontal>
  <horizontal horizontal-fit="PreferredSize">
    <grid cell-size="36 9" spacing="2 2" align="Center">
      <macro.for-each items="buttons">
        <button id="menu-button" pref-width="36" pref-height="9" text="~text" on-click="button-click"></button>
      </macro.for-each>
    </grid>
  </horizontal>
</vertical>
using System;
using System.Collections.Generic;
using System.Linq;
using BeatSaberMarkupLanguage.Attributes;
using BeatSaberMarkupLanguage.MenuButtons;
using BeatSaberMarkupLanguage.Parser;
using BeatSaberMarkupLanguage.ViewControllers;
using Random = UnityEngine.Random;

public class TestViewController : BSMLResourceViewController
{
    public override string ResourceName => "Path.To.Resource.example.bsml";

    [UIValue("buttons")]
    private List<object> buttons = Enumerable.Range(1, 12)
                                             .Select(i => {
                                                 if (i == 1)
                                                     Random.InitState((int)DateTime.Now.Ticks);
                                                 var nthUniverse = Random.Range(0, 100);
                                                 return new MenuButton($"Universe {nthUniverse}!", "", () => Logger.log.Info($"You entered the universe {nthUniverse}")) as object;
                                             }).ToList();
}

This example will display some buttons inside a grid logging some information.