Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Weird cutouts in text appearing randomly

Discussion in 'UGUI & TextMesh Pro' started by Kekito, Feb 12, 2019.

  1. Kekito

    Kekito

    Joined:
    Nov 24, 2016
    Posts:
    14
    These weird glitches appear only after some time of using an app, and disappear after restart, only to reappear after random time period. As you can see not all text is affected even tough it uses the same font and material.
    it looks as if other objects/sprites cut out the letters..

    What could be the cause of this bug?



     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Are you using TextMesh Pro?

    If so, are you using a mixture or normal <TextMeshPro> objects and <TextMeshProUGUI> objects where these objects share the same material? If that is the case, then most likely the world space objects using the Mesh Renderer are fighting over the ZTest of the material with the Canvas system. The same could also happen between Screen Space overlay object and World Space objects.

    Again assuming you are using TMP, the solution would be to use a different set of materials for the normal <TextMeshPro> objects vs. <TextMeshProUGUI> to avoid this conflict.
     
  3. Kekito

    Kekito

    Joined:
    Nov 24, 2016
    Posts:
    14
    Yes, I'm using TMP and I'm using different materials for <TextMeshPro> and <TextMeshProUGUI>. As I understand I just need to make a copy of the same material and and assign one version for all TextMeshPro elements and another for TextMeshProUGUI elements?

    Here is my TextMeshProUGUI material

    and TextMeshPro material
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    That is correct. Just make sure that both materials still reference the same atlas texture from the font asset they are both using.

    Another way to create those materials is to use the Context Menu - Create Material Preset from the material inspector of any text object where the newly created material preset is automatically assigned to the existing text object.

    Also note that in order for Material Presets to be found for a given font asset / to be listed in the Material Presets property of the text object, the name of the Material Preset must be prefix with the name of the font asset. So if the font asset is named "Anton SDF" then presets should be named something like "Anton SDF - Preset 1" or "Anton SDF - Drop Shadow", etc.

    I am unclear if you were using different sets of material already or if you are now switching to using separate sets.
     
  5. Kekito

    Kekito

    Joined:
    Nov 24, 2016
    Posts:
    14
    Yes, I was already using different materials.
    I noticed, that some of the materials do not use mobile TMP shaders (as show in previous images), but instead use normal TMP shaders, and those that do not use mobile shaders seem to work fine (attached image - Level Complete shown correctly, while others words, which use mobile shaders are not properly displayed). So the issue maybe realted to that.
    What is the difference between using mobile and not mobile shaders?
     

    Attached Files:

  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    The difference is related to performance mostly due to offering a more limited feature set but that would not result in the text to stop rendering correctly at some point.

    Can you take a look at the Materials that exhibit the issue and let me know what their Custom Render Queue value is. You will need to switch the inspector to debug mode to see that.

    Then just for testing and rule out the shader, create a new material preset from the default material of the font asset using the context menu - Create Material Preset. Then switch the shader to the mobile one and see if the issue still occurs.
     
  7. Kekito

    Kekito

    Joined:
    Nov 24, 2016
    Posts:
    14
    Every text material has a custom render value of -1
    So as I noticed, I have to create a separate material preset for each font asset I'm using?
    Also, searching by component name in hiearachy doesnt find all of TextMeshProUGUI objects, even though I double checked that all of the text components in the scene are TextMeshProUGUI
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    If you are exclusively using the Canvas system with the <TextMeshProUGUI> component type, you should not need to create separate sets of material presets.

    In terms of Material Presets, these are specific to each font asset so if you need plain text, text with an outline and outline + drop shadow, then plain text would be handled by the default material of the font asset. Then outline and outline + drop shadow would be two additional material presets for a total of four materials.

    How long does it take for the issue to occur?
     
  9. Kekito

    Kekito

    Joined:
    Nov 24, 2016
    Posts:
    14
    The issue of not finding compenent trough hierarchy search? It never finds all of the TextMeshProUGUI. Actualy it always finds the same objects.
     
  10. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Are you using the class filter "t:TextMeshProUGUI" to search for those objects?

    You can also use "t:TMP_Text" to find all text objects.
     
  11. Kekito

    Kekito

    Joined:
    Nov 24, 2016
    Posts:
    14
    Yeah, tried everything, maybe there is just a limit to how many objects can be show in search results?

    One more thing, why do some objects have a TMP submeshui object attached to them, while others, using the same properties dont? Can I delete those objects, since they dont seem to do anything?

    As for the main issue, I changed every objects materials, but it may take a while to check if the issue is fixed, since there are no ways to reliably reproduce the issue.
     
  12. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Sub mesh objects are used when the primary font asset doesn't contain certain characters and a fallback is used or when sprites are used in the text. These should not be deleted unless you know that is not the case. The name of the sub mesh object tells you what font asset it is combined with / using.