grid
A 2D grid of cells — board layouts, emoji palettes, image picks. Cells are always data-bound (via cells_key); set selectable: false to make it a display-only board.
C# factory
WidgetDefinitions.Grid( id: "board", rows: 3, cols: 3, cellsKey: "cells", positionX: 0.5f, positionY: 0.5f, sizeW: 0.7f, sizeH: 0.7f);
// Then push cells via screen data:manager.UpdateScreenDataForAll("game", new{ cells = new[] { new { id = "a1", label = "X", color = "#ef4444" }, new { id = "a2", label = "", disabled = true }, // ... }});Wire format
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | yes | |
type | "grid" | yes | |
position_x, position_y, size_w, size_h | number | no | 0..1 anchor + size. |
rows | number | yes | Row count. |
cols | number | yes | Column count. |
cells_key | string | yes | Reads screen.data[cells_key] for the cell array. |
selectable | boolean | no | Default true. Set false for a read-only board. |
Cells shape: { id?: string, label: string, color?: string, disabled?: boolean }. If a cell has no id, the row/column index is used.
Events
| Event type | Payload | Fires when |
|---|---|---|
select | { cell_index: number, cell_id: string } | Player taps a cell. cell_index is row-major (row * cols + col). |
Example
manager.OnInput += (player, evt) =>{ if (evt.WidgetId == "board" && evt.EventType == "select") { int idx = evt.GetInt("cell_index"); boardState.Mark(idx, player.Id); }};