Search Unity

TextMesh Pro Why is TMPInput resizing itself?

Discussion in 'UGUI & TextMesh Pro' started by ledbetterMRI, Jan 16, 2020.

  1. ledbetterMRI


    May 29, 2019
    I have an TMPInput box as part of a horizontal layout group in my UI and it's not behaving as I'd expect it to based on my understanding of the layout documentation.

    • The parent canvas has a layout group that is controlling the child width and force-expanding.
    • When characters exceed the width of the text area, the box gets resized to fit the new value.
    • I don't want this to happen; setting the input box trunicate or to mask doesn't remedy this problem.
    • I have a layout element on the TMPInput gameobject setting the minimum and preferred width on all input boxes, but the width exceeds both of these values regardless.
    Why does the TMPInput & TextMeshProUGUI have an inpact on minimum and preferred widths when the character count increases?

    Attempted solutions:
    • Setting the parent canvas layout group to not force-expand does not stop the auto expansion from the TMPInput component.
    • Turning off width control DOES keep sizes relative, but then I don't get the benefit of resizing to the bounds of the layout group (this is my current solution, as well as manual anchoring as an alternate).

    In the attached screenshot, the first XYZ input line is manually anchored to keep its dimensions relative to each other, regardless of resolution. The line below shows the layout behavior I'm seeing. Any help on how to configure the layout group to keep the initially set dimensions without TMPInput resizing based on current values would be most helpful. Thanks!

    Attached Files: