Author Topic: Frequently Asked Questions  (Read 3834 times)

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5140
Frequently Asked Questions
« on: February 08, 2016, 01:45:15 PM »
1. When I change the material properties of a text object, it affects the other text objects using that same font asset. How do I control what objects are affected by material property changes?
All Font Assets contain a Default Material which gets assigned to the text objects that are using this font asset. Since these text objects share the same material, changes to the material properties of any of them is reflected on all of them. In order to have different visual styles on these objects, you will need to use different Material Presets or instances of the current material assigned to those objects. See this topic for more details. See the following updated video about Creating & Working with Material Presets.

2. I see visual artifacts around the edges of characters. How do I get rid of them?
These artifacts can be caused by material properties like Dilation, Outline, Underlay, etc. As these property values get near their maximum range, parts of adjacent characters in the font atlas texture can bleed into each other. The font Asset Creator inserts padding between characters to prevent this from happening. To make these visual artifacts go away, re-create the Font Asset with a larger padding value. Note that the padding value affects the range of those properties but also affects the sampling quality of the Font Asset. See this topic for more details. See the following updated video about Font Asset Creation which provides information about padding and how it affects material properties and their range.

3. Characters seems to be cut off near their edges, especially when zooming out. How do I fix this?
By default, character sprites are fit tightly around their visible shape. This minimizes overdraw. However, this can cause the described effect. To solve this, enable extra padding in the font settings panel of your text object.

4. Why is the data contained in the TextMeshPro.textInfo class invalid after I just set the text via script?
For optimization purposes, changes to any of the properties of the text object are processed as a group once per frame which happens just before the frame is rendered. Once the text object is re-generated the text object and content of the TextMeshPro.textInfo will be updated. Most of the time, this is fine however for those times where you need a text object to be updated right away, you can use the ForceMeshUpdate() function.

5. My materials appear to be broken. How do I fix them?
Have a look at this video.

6. The Font Asset Creator isn't working. How do I get rid of this error?
On Windows, the Font Asset Creator requires some DLLs that are included in Unity 4, but not in Unity 5. To install the required DLLs, download the Visual C++ Redistributable Packages for Visual Studio 2013 and install vcredist_x64.exe.
On Mac, bundle support for Unity 5.4 was broken, until version 5.4.0b12. If you have this or a later version and you still get an error, select the bundle folder and manually reimport it.

7. How can I use UTF-16 and UTF-32 characters?
You have to use escape codes for such characters. For UTF-16, use codes like \uF199. For UTF-32, use codes like \U00FF00FF. You can add them to the font atlas explicitly in the same way, or use unicode ranges.

8. I have many dynamic text objects with auto-size and the performance is bad. How do I improve this?
Auto-size is expensive, because text layout needs to be performed multiple times to find the best fit point size. If the text is static or remains about the same length, it would be more efficient to only use Auto-size when the text object is first instantiated to find the best fit point size. Thereafter simply disable the Auto-size and manually set the point size via script.

9. Why can't I get the text component via GetComponent<TextMeshPro>()?
You can, but there are actually two different types of TextMeshPro components. Non-UI text components have the TextMeshPro type, as expected which can be access using GetComponent<TextMeshPro>(). The UI text components have the TextMeshProUGUI type. You can get those via GetComponent<TextMeshProUGUI>(). Both TextMesh Pro components inherit from a base class which is TMP_Text where you can also get a reference to either types of TextMesh Pro components by using GetComponent<TMP_Text>(). To access these components in your scripts you will also need to include the "using TMPro;" namespace.

10. How can I assign a different material to my text object?
You can apply a different material by dragging it from the project view onto the material inspector of the text object. Have a look at this video. To create a material variant, duplicate the material via it inspector's context menu, then adjust as desired.

11. How can I increase the range of text effects like dilation, outline, and underlay?
The range of these effects is determined by the padding used when creating the font atlas. The larger the padding, the larger the effect range. Of course more padding means less room for character data. So there is a trade-off between character quality and effect range. Use the smallest padding that works for you. Note that the padding is specified in pixels, so if you double the texture size you also have to double the padding to keep the same range. See here and here for more details. See the following updated video about Font Asset Creation which provides information about padding and how it affects material properties and their range.

12. Can I use drop caps?
While there is no special support for drop caps, you can create them with some creative use of rich tags. See this topic for details.

13. Can I put text on a curve?
Yes you can, with some custom work. There is a sample script available in this topic.

14. Can I edit the width and height of the text object, while in the 3D scene view?
Yes, by using the RectTransform tool, which has hotkey T. There used to be a custom scene UI for resizing, but it has been removed in version 0.1.54 beta 1.

15. Why doesn't the font tag load my custom font?
Your font asset has to be placed in a Resources folder. Specifically, Resources/Fonts & Materials. You'll be able to adjust the subfolder in an upcoming release. Both the path and asset name are case sensitive.

16. Why is a tag rendered as text, instead of being used for rich text?
When a tag doesn't work, it is shown as plain text. This is done so you can see that there is something wrong and can identify the problem. Failure can be caused by invalid tags, missing or invalid tag arguments, or because sprite or font resources could not be located.

17. I upgraded and old version of TextMesh Pro. Outlines disappeared. How do I get them back?
Old shaders didn't use a keyword to toggle the outline functionality. Newer shaders do. They're turned off by default, which is why the old outlines disappeared. To get them back, you'll have to manually toggle the outlines via the material inspector.
If you want to toggle outlines at run time, there are two ways to do this. The simple approach is to enabled outlines and set their thickness to zero. The other way is to set the appropriate keyword via a script and make sure that the required shader variants are included in builds.
« Last Edit: March 27, 2017, 12:19:02 PM by Stephan B. »