Search Issue Tracker
By Design
Votes
0
Found in
6000.0.59f1
6000.2.7f1
6000.3.0b4
6000.4.0a1
Issue ID
UUM-120499
Regression
No
TextMeshPro text is misaligned when alignment is set via script
How to reproduce:
1. Open the “IN-115640_TMProAlignmentBug“ project
2. Open the “Assets/Scenes/TMPAlignmentIssue” Scene
3. Enter Play Mode
4. Observe the “Text (TMP)” GameObject in Scene view
Expected result: The text is aligned correctly and is within the rect bounds
Actual result: The text is out of the rect bounds
Reproducible with: 2023.2.0a17, 6000.0.59f1, 6000.2.7f1, 6000.3.0b4, 6000.4.0a1
Reproducible on: macOS 15.6.1 (M1 Max), Windows 10 (by user)
Not reproducible on: no other environments tested
Note: If you manually select the vertical alignment for the Script component attached to the TMP GameObject the issue is no longer reproducible
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
Resolution Note:
In the repro project and although the alignment options of the TMP Test script appear to be set to top left, since this value has never been serialized in the scene, the value is actually zero.
To confirm this, simply open the scene file in some text editor and search for alignment where you will see it is set to zero.
As such, this corresponds to the text being aligned where the origin of the first character is aligned with the pivot of the RectTransform which is correct.
If you were to change the properties of the Alignment field in the Tmp Test Script, it would then serialize that new value where it would then work as expected.
In summary, this is the result of the alignment serialized property never having been serialized where by default it is set to zero even though in the inspector is would seem to be set to Top Left.