Skip to content

MaxTMProSize

Ilia Petrov-Komotskii edited this page Sep 24, 2026 · 7 revisions

MaxTMProSize

Caps a TextMeshProUGUI preferred size through a sibling LayoutElement. Zero on an axis means no cap (preferredWidth / preferredHeight = -1).

Requires TextMeshProUGUI and LayoutElement on the same GameObject (ExecuteAlways, one instance per object).

using Mane.Unity.UI;

maxSize.MaxWidth = 240;  // pixels
maxSize.MaxHeight = 0;   // unlimited height

Update recalculates when the TMP text string changes. Setters clamp negative values to 0.

Inspector

Custom ManeEditor (UXML). Width/height fields use LimitedValueField: 0 shows as unlimited rather than a raw zero.

Use it inside a layout group when a label should grow with text but not blow the layout.

Screenshot: max-tmpro-size.png — TMP in a Horizontal Layout Group, width capped, height unlimited. Host at https://raw.githubusercontent.com/wiki/ManeFunction/ManeTools-UnityUI/max-tmpro-size.png.

Clone this wiki locally