Search Issue Tracker
Won't Fix
Won't Fix in 2023.2.X
Votes
1
Found in
2021.3.14f1
2022.1.8f1
2022.2.0b1
2023.1.0a3
2023.2.0a1
Issue ID
UUM-8490
Regression
No
"TextElement.MeasureTextSize" returns incorrect Text size in a Text Field
How to reproduce:
1. Open project “MeasureTextSizeIssue.zip”
2. Open Menu > Bug > Search Toolbar
3. Type in the Text Field until text reaches a placeholder
4. Observe the placeholder
Expected result: Text “Press Tab to filter” disappears before Text reaches it
Actual result: Text “Press Tab to filter” disappears after Text reaches it
Reproducible with: 2022.1.8f1, 2022.2.0b1, 2023.1.0a3
Could not test with: 2020.3.36f1, 2021.3.6f1 (Errors after project downgrade)
Reproduced on: macOS 12.4 (Intel)
Note: reproducible when Text font size is 13px and above
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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
Resolution Note:
In the provided repro project, there are multiples textElement in the SearchToolbar, the visualElement.Q return the first element that match the query, and in this case it was the button and not the text field's textElement. Because of this, it was using the button style to measure the text.
Changing the line where we obtain the textElement like this solved the issue:
var te = textField.Q<TextElement>();
Resolution Note (2023.2.X):
In the provided repro project, there are multiples textElement in the SearchToolbar, the visualElement.Q return the first element that match the query, and in this case it was the button and not the text field's textElement. Because of this, it was using the button style to measure the text.
Changing the line where we obtain the textElement like this solved the issue:
var te = textField.Q<TextElement>();