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

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.

1 Like

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.

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

Procedure 1 to 4

6078996--659598--4.gif
6078996--659601--3.gif
6078996--659604--2.gif
6078996--659607--1.gif

1 Like

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.

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.

1 Like

same here with TMP 2.1.3, but it can be fixed by duplicating the font asset and changing his default material

I’ll have to look at the Tutorial to figure out the potential issue.

1 Like

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.

2 Likes

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.

If anyone has this issue, it seems that "
public static Material[ ] FindMaterialReferences(TMP_FontAsset fontAsset)" from TMP_EditorUtility.cs searches for materials that start their name the same as the font asset name:

string searchPattern = "t:Material" + " " + fontAsset.name.Split(new char[] { ' ' })[0];

When creating a preset, just give it a unique name that starts the same as the font asset name and it will appear in the list.