logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityTextMeasurementUtils

    Measurement helpers for TextMeshPro texts, shared by every module that sizes rects around TMP labels.

    Inheritance
    object
    UnityTextMeasurementUtils
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Global.Infrastructure.Utils
    Assembly: Serenity.UnityGlobal.Infrastructure.dll
    Syntax
    public static class UnityTextMeasurementUtils

    Methods

    ComputePreferredWidth(TMP_Text, string)

    Computes the single-line width content would render at, using text's current font, font size and style. Callers that measure a worst-case width (e.g. before auto-sizing shrinks a label) pass a probe already configured at its maximum font size.

    Declaration
    public static float ComputePreferredWidth(TMP_Text text, string content)
    Parameters
    Type Name Description
    TMP_Text text
    string content
    Returns
    Type Description
    float

    ComputeSingleLineHeight(TMP_Text)

    Computes the text's worst-case single-line height: the auto-size ceiling (fontSizeMax) scaled by the font's real faceInfo lineHeight/pointSize ratio -- script fonts carry ratios well above the 1.25 fallback used when no font is resolvable. Rects sized from this can never trigger TMP's vertical whole-line cull at any size auto-sizing may settle on.

    Declaration
    public static float ComputeSingleLineHeight(TMP_Text text)
    Parameters
    Type Name Description
    TMP_Text text
    Returns
    Type Description
    float
    In this article
    © 2026 Serenity. All Rights Reserved