Skip to content

MaxTMProSize

Ilia Petrov-Komotskii edited this page Oct 6, 2026 · 7 revisions

In terms of localization and UI counters, base Unity tools let you either define a static layout and vary the font size (which leads to inconsistent text, weird spacing and a different font size for every label) Defined by Layout

or let you size the text's parent by the length of the text (which makes it inconsistent with other layout elements). Defined by Text

In some cases it even blows up your UI, making it impossible to make different controls work together. Layout blowup

MaxTMProSize minimizes the downsides of these two approaches by combining them. Layout size is still driven by the text label, but now you can set a Maximum Width: Max Width

and Maximum Height, if you need it. Max Size both

MaxTMProSize caps a TextMeshProUGUI's 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

Inspector

Custom ManeEditor (UXML). Width/height fields use LimitedFloatField (decimal values are allowed): 0 shows as unlimited rather than a raw zero.

Clone this wiki locally