Search Unity

TextMesh Pro Can't use multiple material preset with Custom Font Atlas?

Discussion in 'UGUI & TextMesh Pro' started by 8h8h8h, Jul 11, 2020.

  1. 8h8h8h

    8h8h8h

    Joined:
    Jul 7, 2015
    Posts:
    4
    Hi. I'm trying to use multiple material preset with Custom Font Atlas. but It seems not intended.

    I proceed in the following order.
    1. Create Font Asset with Font Asset Creator. Font Asset have default material and default atlas.
    2. Create new Atlas png in Font Assset inspector - gear wheel button - Extract Atlas.
    3. Change Font Atlas In Default material inspector - Debug Settings - Font Atlas (change new one)
    4. Make new Material In Default material inspector - gear wheel button - Create Material Preset click.(didn't change any variables)
    5. Create TextMeshPro - Text (UI) Componet and set font asset.
    6. Can see Material Preset dropdown have two material(default one, new one)
    7. Trying to change Material Preset to new one but not changed and noting happen.
    8. If change material using Drag & Drop. it is changed but when save and reload scene or reopen project, material preset is set default material.

    Can't change new material preset when changed debug settings Font Atlas in Default material.(tried copy atlas, paste atlas, tried every textmeshpro shader(bitmap, custom atlas, disance..))
    Is this intended? it work when Font Atlas is set Default Atlas.

    Thank you.
     
    Eater_Games likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Is this a bitmap font asset?

    After step 2, are you editing this font atlas in some external tool?

    I'll test the procedure you outlined tomorrow.
     
  3. 8h8h8h

    8h8h8h

    Joined:
    Jul 7, 2015
    Posts:
    4
    I had several case test
    case 1. Tested with Default Font asset "LiberationSans SDF" - default material with any change. and continue 2 to 8 procedure
    case 2. Create Font Asset with default font "LiberationSans" with procedure.
    case 3. Create Font Asset with other font. And change Default material shader (Bitmap, Bitmap Custom Atlas, Distance Field, Sprite..)

    Weird thing is that Material Preset have created material(have same extract atlas) but no change when select. Keep selected default material.
    But everything is OK when not using extract Atlas (material's debug setting - Font Atlas is Default Atlas)

    Should i do some setting when create Font Asset for using custom atlas?

    And after procedure Step2, Just Extract Atlas and didn't edit atlas and didn't change any Import setting(Texture type, sprite mode..)

    Tested In Unity 2019.4.3f1 and 2019.3.1f1
    Textmesh Pro 2.0.1
     
  4. 8h8h8h

    8h8h8h

    Joined:
    Jul 7, 2015
    Posts:
    4
    Procedure 1 to 4
     

    Attached Files:

    • 4.gif
      4.gif
      File size:
      207.7 KB
      Views:
      495
    • 3.gif
      3.gif
      File size:
      236 KB
      Views:
      497
    • 2.gif
      2.gif
      File size:
      124.5 KB
      Views:
      477
    • 1.gif
      1.gif
      File size:
      147.1 KB
      Views:
      461
    Stader likes this.
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I am still trying to understand why you are extracting the atlas texture from the font asset and then assigning it to some other material instead of just using the context menu to create a Material Preset which does that automatically.

    Why are you trying to use a custom atlas?

    Also be sure to use version 2.1.0 of the TMP package.
     
  6. 8h8h8h

    8h8h8h

    Joined:
    Jul 7, 2015
    Posts:
    4
    I was trying to use Custom font. So I tried to edit the atlas extracted using Photoshop, etc.
    I'm tying to tell there is a same problem without external modification.

    This video is what I am trying to do.


    also seems like same in version 2.1.0

    I found out the component
    "TextMeshPro - Text" with that Font Asset - Working.
    "TextMeshPro - Text (UI)" with Font Asset - Not working.

    I am wondering using material in "TextMeshPro - Text (UI)" component is not intended or technically impossible.
     
    Last edited: Jul 12, 2020
    Eater_Games likes this.
  7. Eater_Games

    Eater_Games

    Joined:
    Mar 19, 2018
    Posts:
    4
    same here with TMP 2.1.3, but it can be fixed by duplicating the font asset and changing his default material
     
    Last edited: Nov 28, 2020
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll have to look at the Tutorial to figure out the potential issue.
     
    Eater_Games likes this.
  9. lunoland

    lunoland

    Joined:
    Aug 4, 2016
    Posts:
    12
    I also ran into this issue using 2019.4.40f1 and TMPro 2.1.4 but discovered a work around!

    When you assign a custom atlas to the font asset, it retains a reference to the original atlas in the private "Atlas Texture" field regardless of what you assign to the "Atlas" and "Atlas Textures" fields on the font asset using debug mode in the inspector.

    As a result, when you create material presets for that font, they appear in the drop down on text mesh components but you cannot select any preset besides the default. I assume this is because the custom atlas texture on your new material does not match the texture referenced in "Atlas Texture".

    The fix is:
    1. Duplicate the font asset. For whatever reason, when you do this the private "Atlas Texture" field becomes unassigned on the new asset.
    2. On the new copy of the font asset, switch the inspector to debug and assign your custom atlas to the "Atlas" field and the first element of "Atlas Textures".
    3. Don't forget to assign your custom atlas to the "Font Atlas" field on the material (If you're using your own shader, _MainTex).
    4. The next time you select this font on a text mesh component, the private "Atlas Texture" field will be updated to the correct, custom atlas and your material presets work again!

    ---

    My use case for wanting a custom, modified atlas is probably pretty common: I want to use bitmap pixel art fonts that I create with my own bitmap shader (the fonts have outline and text effect data baked into the colors). It's also a really nice workflow for a pixel art game to be able to easily modify your fonts (e.g. add/change glyphs) by editing a sprite sheet.
     
    TeamHoray and Eater_Games like this.
  10. JordiRM

    JordiRM

    Joined:
    Jan 7, 2015
    Posts:
    2
    Same issue here using 2020.3.20f1 and TMP 3.0.6
    The strange metod works... until i change the Font Atlas in Debug Settings of the shader Bitmap Custom Atlas.
    From there, the preset stops appearing in the list.
    As far as I know, that Font Atlas is the only place I can put my new atlas to modify the appearance of the font.