I’m using the Bitmap Custom Atlas shader and changing the Font Atlas under debug settings of the material.
If I create a font asset and a few material presets, I can get any chosen material preset to persist within a prefab.
However, the moment I change any of these materials Font Atlas’ - the option won’t persist.
I’ve been trying to debug the issue to see what it might hit in TMP for this but I’m a bit lost.
edit: Quick repro -
- Default LiberationSans SDF font asset - change the Font Atlas to any other texture for now.
- Create a prefab of a TMP object
- Create material preset for font asset
- Set prefabs material preset to new preset, save
- Close prefab
- Open prefab - preset didn’t persist
I know editing the font atlas might be a bit of an odd use case, I don’t mind doing some custom implementation within TMP to work around it.
Prefab seems to serialize property change correctly. If I click the prefab once in editor, I can see the correct material preset.
The moment I open the prefab in the prefab editor, the material preset is lost.
edit:
nvm - found it 
TMPro_Private
// If font atlas texture doesn't match the assigned material font atlas, switch back to default material specified in the Font Asset.
if (m_sharedMaterial == null || m_sharedMaterial.GetTexture(ShaderUtilities.ID_MainTex) == null ||
m_fontAsset.atlasTexture.GetInstanceID() !=
m_sharedMaterial.GetTexture(ShaderUtilities.ID_MainTex).GetInstanceID())
{
if (m_fontAsset.material == null)
Debug.LogWarning(
"The Font Atlas Texture of the Font Asset " + m_fontAsset.name + " assigned to " +
gameObject.name + " is missing.", this);
else
m_sharedMaterial = m_fontAsset.material;
}
1 Like
Hello @pikminscience
Did you ever figure out what is going on with this issue? I think I am running into the same thing.
I wonder if a fix was ever found and released? I am using LTS 2022.3.9f1
Thank you
1 Like
Hey, sorry - super late; might still be handy for someone.
I branched the package and commented out some statements:
TMPro_Private:
if (m_sharedMaterial == null || m_sharedMaterial.GetTexture(ShaderUtilities.ID_MainTex) == null)
// ||
// m_fontAsset.atlasTexture.GetInstanceID() !=
// m_sharedMaterial.GetTexture(ShaderUtilities.ID_MainTex).GetInstanceID())
{
if (m_fontAsset.material == null)
Debug.LogWarning(
"The Font Atlas Texture of the Font Asset " + m_fontAsset.name + " assigned to " +
gameObject.name + " is missing.", this);
else
m_sharedMaterial = m_fontAsset.material;
}