Search Unity

TMP Underlay issue (works in editor but not in PC standalone build)

Discussion in 'UGUI & TextMesh Pro' started by keshet, Sep 10, 2018.

  1. keshet

    keshet

    Joined:
    Sep 22, 2015
    Posts:
    5
    Wondering if anyone else has had this issue and what might be the problem. TextMeshpro object with underlay on works fine in the editor, but in my PC standalone build, it isn't visible.
     
  2. keshet

    keshet

    Joined:
    Sep 22, 2015
    Posts:
    5
    Some extra info on this, when i jsut have the text object in scene it works, but the app allows the user to create text objects and style them. Enabling the underlay works in editor but not in the build. outline works fine, also tried changing which shader is used.
     
    Last edited: Sep 10, 2018
  3. keshet

    keshet

    Joined:
    Sep 22, 2015
    Posts:
    5
    A quick patch fix, and extra info part 2. I have sort of patched it by enabling the underlay on all my font materials. Then when i create the text object, I just turn off the underlay. I am now able to add and remove and adjust like normal.

    The underlay used to work fine on the last version of unity I was using, 5.6, before i updated to unity 2018
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    The outline and underlay use a Keyword which might not be getting set correctly.

    What version of the TMP package are you using with 2018?
     
  5. keshet

    keshet

    Joined:
    Sep 22, 2015
    Posts:
    5
    It is whatever is the most current version. I tried importing the whole things to see if that was the issue.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I have a feeling the issue is simply related to the shader keyword to enable the Outline or Underlay not getting set on the newly created user material. So I would look there.
     
  7. peledkfir

    peledkfir

    Joined:
    Nov 10, 2016
    Posts:
    2
    I'm experiencing the same issue on webgl..
    Creating new game object in runtime and setting like so (look at pseudo). The underlay is visible using the editor. however, when running inside the webgl it doesn't showed up

    Code (CSharp):
    1.  
    2. private readonly TextMeshProUGUI _textComp;
    3.  
    4. _textComp.fontMaterial.EnableKeyword(ShaderUtilities.Keyword_Underlay);
    5. _textComp.fontMaterial.SetColor(ShaderUtilities.ID_UnderlayColor, color);
    6. _textComp.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlayOffsetX, 0.5f);
    7. _textComp.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlayOffsetY, -0.5f);
    8. _textComp.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlaySoftness, 0.05f);
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    First create a material preset with those settings to make sure that works on WebGL. It should work but this would enable us to rule out any other potential issues.

    Then be mindful that accessing the .fontMaterial will result in an instance being created automatically. If that is what you want, the perhaps create the material on your own and then modify its properties. This would make it easier for you to manage this material especially if you have more than one object using this where you should then share this material with all of them.

    Let me know what happen with the material preset and underlay.
     
  9. peledkfir

    peledkfir

    Joined:
    Nov 10, 2016
    Posts:
    2
    So I've actually tried now @keshet 's workaround and it worked perfectly. Setting the defaults font's material with underlay enabled, and later on switching that flag on/off made it work perfectly..

    As for the material presets, I'm coding all my UI using code. And by having several fonts, I prefer creating the presets in code and caching each preset on my end.

    If you wish, I'll try what you say and set the default material with Underlay off, and create a new preset material, if that is why causing the issue (perhaps code generation being done during compilation?)
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    That is totally fine. Just make sure the you keep in mind that assigning a new material to the fontMaterial property will results in creating a new instance whereas assigning it to the fontSharedMaterial will not. So if you create your material instance ahead of time / cache it and then assign it to all relevant objects using the fontSharedMaterial property then you will have only once instance shared between all these objects.

    I also suspect the issue you are having is related to this instancing where you might be changing the underlay keyword on some material but not on the correct instance (possibly).
     
  11. megagon

    megagon

    Joined:
    Jan 7, 2016
    Posts:
    2
    Having the same issue with the 2018.2.15f1 version with the newest TextMeshPro Package 1.3.0. Is there are an official fix on the way or do we still have to use the workaround through the default font?