Search Issue Tracker
By Design
Votes
1
Found in [Package]
3.0.3
Issue ID
1286312
Regression
No
[TMP] Soft hyphen Unicode is outputted when setting it through script if OnValidate is not used
Reproduction steps:
1. Open the attached Project "SoftHyphenation.zip"
2. In the Project Window under "Assets/Scenes" open "SampleScene.unity"
3. In the Hierarchy Window select the "HyphenationTest" GameObject
4. In the Inspector Window check the "Set Without Validate" property of "HyphenationTest" Script and enter Play Mode
Expected result: "Speditionskauffrau/mann" text is outputted
Actual result: "Spe\u00ADdi\u00ADtions\u00ADkauf\u00ADfrau/\u00ADmann" text is outputted if OnValidate is not used (attached Results.mp4)
Reproduces on: TMP 1.5.3 (2018.4.29f1), TMP 2.1.3 (2019.4.15f1), TMP 3.0.3 (2020.1.14f1, 2020.2.0b12, 2021.1.0a6)
Notes:
-If OnValidate is enabled, the text is outputted as expected
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
- Performance Markers Search window shows an empty entry in the list
- Enabling Deep Profiling in Performance Markers Search window breaks Inspector panel buttons when navigating through the marker items
- Dragging selector from selector row background shows preview but does not apply class in UI Builder
- An "InvalidOperationException" error is thrown when TryRemoveItem is used with rebuildTree set to false
- Build fails with IL2CPP error when building on Android platform in a specific project
Resolution Note:
This is not a bug but rather due to the use of "@" in front of the string which forces the string to be interpreted as a string literal where \u00AD is exactly those 5 characters instead of the interpreted single character soft hyphen.
Removing the "@" in front the string will result in the text string being interpreted correctly. This is a C# convention and not specific to TMP.
In terms of why calling OnValidate() results in the soft hyphen being interpreted correctly, that is simply due to the manual calling of OnValidate() tricking the text object in thinking the text is coming from the Text Input Box in the Inspector where there is special handling to allow users to enter Unicode Escape Sequences like \u00AD for UTF16 or \U000000AD for UTF32.
I replied to the original post to provide this information.