Class MenuPreviewBuilder
Builds a real, themed menu into a preview canvas using the chosen theme's actual prefab templates
(background, title, per-interaction option rows), positioned with a layout pass that mirrors the runtime
UnityMenuLayoutBuilder — direction, gaps, alignment, the horizontal width modes and the
scroll clamp — without needing any runtime services. The components' own scripts do not run in edit mode
(no [ExecuteAlways]), so only their serialized visuals (Image/TMP/Slider state) are rendered.
Inherited Members
Namespace: Serenity.Ui.Infrastructure.Editor.Preview
Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
Syntax
public static class MenuPreviewBuilder
Remarks
Keep the layout math here in sync with SetMenuArea(IMenuSettingsDefinition, Dictionary<string, GameObject>, UnityMenuView, IUiThemeDefinition, float); both measure widths through the shared pure UnityMenuMeasurementUtils.
Methods
BuildMenu(UnityMenuSettingsDefinition, UnityUiThemeDefinition, RectTransform, int, bool)
Builds menu with theme under parent.
Declaration
public static MenuPreviewResult BuildMenu(UnityMenuSettingsDefinition menu, UnityUiThemeDefinition theme, RectTransform parent, int selectedIndex, bool fillBackgroundToParent = false)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityMenuSettingsDefinition | menu | The menu definition to render. |
| UnityUiThemeDefinition | theme | The theme whose prefab templates supply the visuals. |
| RectTransform | parent | The region the menu occupies (a preview canvas, or a composite child rect). |
| int | selectedIndex | Which option shows the selection highlight. |
| bool | fillBackgroundToParent |
Returns
| Type | Description |
|---|---|
| MenuPreviewResult | The per-option rects + scroll info for the window to overlay/hit-test. |