Search Unity

Fallback fonts not using parent material properties; prevents game localization

Discussion in 'UGUI & TextMesh Pro' started by Pattrigue, Dec 27, 2021.

  1. Pattrigue

    Pattrigue

    Joined:
    Nov 24, 2018
    Posts:
    67
    Hi,

    I have been implementing TextMeshPro into my game and I have run into a bit of a roadblock.
    I cannot get TMP_SubMeshUI to use the parent material properties. No matter what, it always just uses the default material preset. This is preventing me from localizing my game.
    I have made sure Match Material Presets is enabled too.

    I want to use fallback fonts for things like icons and localization, yet it doesn't seem to work as the documentation claims: "When Match Material Presets is enabled, fallback materials will be instantiated that match the settings of the material of the font that was missing the glyph. That way, the fallback characters have the same style as the other characters." (source: http://digitalnativestudios.com/textmeshpro/docs/settings/)

    The following images show the problem.
    It should be evident that the glyphs from the fallback font do not have the same color/shadow as its parent as they are not using the same material.


    The Japanese symbol should look the same as the Latin characters.


    The gem should look the same as the "1-".

    I am using Unity 2019.4.32 and TextMeshPro version 2.1.6.
     
  2. Pattrigue

    Pattrigue

    Joined:
    Nov 24, 2018
    Posts:
    67
    Okay, so I've been doing a lot of digging.
    I noticed that only certain built-in shaders like the distance field shader had their material properties copied to sub meshes while the bitmap one did not.

    As it turns out, for some reason, TMP only copies material properties IF the shader has a _GradientScale property.
    This can be seen in TMP_MaterialManager.cs on line 597.
    upload_2021-12-28_12-48-56.png

    As soon as I added this property to my own custom bitmap shader, it works as expected.

    Why is this not documented anywhere? And why is this even a requirement in the first place???
    I'm not using the property, I just HAVE to include it or TMP doesn't copy the material properties to sub meshes.

    Please document this somewhere or remove this strange shader requirement.
     
    pikminscience and rin-2 like this.