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
- "One or more data file missing for baking set NewScene Baking Set. Cannot load shared data." error in Player when a specific project is built
- Choosing new HDR Colour using RGB values breaks colour on Intensity Selectors
- Rendering/Decal Layer Mask options are different inside Prefab Mode and outside Prefab Mode when the project is upgraded to Unity 6
- Incorrect Realtime GI Light Probes baking when more than one Light Probe Group is used and "Baked Global Illumination" is enabled
- Hovering on the three-dot menu also highlights the tab header near it when not all tabs fit the bar
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.