Display a board with uGUI
When to use
Use uGUI, a Preview-tier module, when a board belongs in a Canvas interface such as an inventory or puzzle screen. The procedure below configures retained rendering only; pointer interaction is a separate, optional step.
Before you start
Retained uGUI rendering requires Unity's com.unity.ugui 2.x package, a ready board owner, a Canvas,
GridBoardView, and
GridCanvasBoardRenderer.
An EventSystem, input module, and raycastable content are not required merely to display the board.
Procedure
1. Connect the Canvas renderer
- Add
GridCanvasBoardRendererbelow the target Canvas. - On
GridBoardView, assign the component that provides board state and assign the Canvas renderer as its only renderer.
When a project-owned component performs the binding, keep that operation focused:
Excerpt — connect the Canvas view to its state owner. Tested using public APIs.
public void Bind(IGridBoardStateSource stateSource)
{
boardView ??= GetComponent<GridBoardView>();
if (boardView == null)
throw new InvalidOperationException("A GridBoardView is required.");
boardView.SetStateSource(stateSource);
}
2. Choose visible content
- Assign a compatible layout provider and cell node builder to the Canvas renderer. A cell builder is required to see cells.
- Add structure builders only for structures that should be visible. For an authored library,
assign the same
GridStructureLibraryAssetused by the board setup. - For image-backed structures, create and assign GridStructureUiImageVisualAsset and configure its GridUiImageSettings.
3. Verify the rendered board
Enter Play Mode. Confirm that the view is bound, the Canvas renderer is ready, and the expected cell and structure nodes are visible.
Result
The Canvas contains retained cell and structure nodes. The view reports a bound state, the renderer reports no configuration diagnostic, and board commits update existing uGUI nodes without rebuilding the logical board.
Troubleshooting
| Symptom | Check |
|---|---|
UnityEngine.UI types are missing |
Resolve the required com.unity.ugui 2.x dependency. |
| The Canvas is visible but the board is empty | Confirm the view is bound and ready, then check its layout, renderer, and cell builder. |
| Structures are missing | Assign their uGUI visual assets and the same library used by the authored setup. |
| Images have the wrong size | Validate sprite, native size, aspect, and GridUiImageSettings. |