Skip to content

Instantly share code, notes, and snippets.

@sukedon
Last active February 13, 2024 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sukedon/151abb851921f8a9e38cb86647f61a61 to your computer and use it in GitHub Desktop.
Save sukedon/151abb851921f8a9e38cb86647f61a61 to your computer and use it in GitHub Desktop.
TextMeshProのdynamicなフォントの差分をでなくするやつ
using UnityEngine;
using TMPro;
using UnityEditor;
[InitializeOnLoad]
public static class DynamicFontCleaner
{
static DynamicFontCleaner()
{
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
private static void OnPlayModeStateChanged(PlayModeStateChange state)
{
if (state == PlayModeStateChange.ExitingPlayMode)
{
var tmpFontAssets = Resources.FindObjectsOfTypeAll<TMPro.TMP_FontAsset>();
foreach (var tmpFontAsset in tmpFontAssets)
{
if (tmpFontAsset != null && tmpFontAsset.atlasPopulationMode == AtlasPopulationMode.Dynamic)
{
tmpFontAsset.ClearFontAssetData();
Debug.Log("DynamicFontCleaner: ClearFontAssetData " + tmpFontAsset.name);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment