If you use the Font Asset Creator to make a TextMeshPro .asset from a font you get a .asset file that has an embedded material and atlas.
A while ago I created a font asset then renamed it when I changed how I was using it. It seems that the material and atlas embedded in the file have the original asset name burnt into their names. Is there any way to rename these or force them to refresh their name?
As far as I know, this is not possible in the Editor. It should be possible via some Editor script / tool using the AssetDatabase class and functions.
However, if you only need to do this once, you could cheat and simply edit the font asset file. In the font asset file look for Material: and then m_Name: and then Texture2D: and again m_Name: to rename those sub objects.
@Stephan_B I’d like to be able to do this in a large project right now to do a gamewide font swap quickly and easily. I’ve had a realization that you may already have had:
If I rename my original fonts (TTF/OTF files) to TitleFont, BodyFont, etc. to begin with, I’ll end up with a TitleFont atlas and TitleFont material embedded. Then, if I want to use a different title font in my game, all I have to do is regenerate my TitleFont atlas with glyphs from the new font and adjust the TMP asset settings. This way I can avoid editing every last prefab in the game manually to achieve the font swap.
I can currently rename my title font asset and its related material variants to TitleFont successfully, but I’ve had no success renaming the embedded child material and atlas. I don’t mind editing some asset file in a text editor, but I keep getting fatal errors in Unity when attempting to do so. Would you mind specifying how to do this?
This remains a mess. If you try to build up a set of fonts, the natural inclination might be to copy the Font Asset and customize. But the names of materials and textures are wrong and shared between fonts, so it’s pulling glyphs from the wrong atlas coordinates.
After editing the files directly, you also should go open some other scene and come back. The re-import does not trigger TMP to update all appropriate information.
In 2021.3 LTS, no matter how many times I try to update this field, it reverts to an earlier value. I quit Unity, I edited the sourceFontFileGUID fields to match the TTFs for each of several fonts, I removed my Library folder, and yet when I come back, this field is wrong. This screenshot is after I tried to associate it with epgyosho; I don’t see any reference to epkyouka or its GUID in the font asset shown here, but the Inspector keeps going back to that value.