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
- Search field in UI Builder's Library has no character limit
- Changing the value in UI Builder by dragging increases it by a few thousand points when reaching the borders of the screen
- ARM64 architecture DLL incorrectly copied instead of x64 when building for Windows x64
- Crash on TypeTreeIterator::GetNode when opening a specific folder
- Crash on WriteSerializedAssetsV2 when (re)entering the Play Mode in a specific project when IEnumerator Start() is used
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.