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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

TextMesh Pro Text Mesh Pro Material Glow not working in Build

Discussion in 'UGUI & TextMesh Pro' started by EpicFlan, May 3, 2023.

  1. EpicFlan

    EpicFlan

    Joined:
    Jan 31, 2020
    Posts:
    5
    I have an issue with my Build, where Text Mesh Pro Material seems to be not working in the Build like how it does in the Game in the Editor. I have a glow effect for the text, and this works fine in the Editor (both Scene view and Game view), but when I actually Build and run the game, these glow effects aren't showing up.

    This is the Game View, running the game in Unity Editor:


    This the full Build:


    It doesn't seem to be an issue with Post-Processing or HDR, as I have other effects in my game which use these, and they all work fine in the Build. Does anyone know why there would be a difference for this between the Game View and the final Build?
     
  2. lharoon_ad

    lharoon_ad

    Joined:
    Jun 22, 2022
    Posts:
    1
    Are you turning the glow on via script (by enabling GLOW_ON in the distance field shader)? If you are, you'll need to make sure that you have a material asset in your project/build that has glow enabled (i.e. that a MonoBehaviour references), or include a shader variant collection. This is because Unity will otherwise strip out the shader variant where glow is enabled from the build, thinking it isn't required at runtime. If you look at the distance field shader code you'll notice that GLOW_ON is defined as a shader_feature. This is the behaviour of shader_features. Another solution is to define this as a multi_compile instead. multi_compile defines force Unity to keep shader variants for every option, whether or not they're referenced in the project. So in the TMP_SDF shader it's a case of replacing

    #pragma shader_feature __ GLOW_ON

    with

    #pragma multi_compile __ GLOW_ON

    Note that this can have an impact on build times & memory usage if they're used extensively across your shaders, since you may be compiling shader variants that you don't actually need. Otherwise you're good to make that change.

    Managed to suss this out thanks to these forum posts
    https://forum.unity.com/threads/enablekeyword-not-working-in-build.1328433/
    https://forum.unity.com/threads/sha...t-not-on-android-device.1192480/#post-7626979

    Check out this link for a comprehensive explanation from the official docs
    https://docs.unity3d.com/Manual/shader-conditionals.html
     
  3. EpicFlan

    EpicFlan

    Joined:
    Jan 31, 2020
    Posts:
    5
    Just got round to seeing this, great work figuring this out! I changed to multi_compile for a quick fix, and the glow shows up in my build now. I'll look into the Shader Variants for a better long term solution. Thanks again for the solution!
     
    lharoon_ad likes this.