Last active
February 13, 2024 17:57
-
-
Save sukedon/151abb851921f8a9e38cb86647f61a61 to your computer and use it in GitHub Desktop.
TextMeshProのdynamicなフォントの差分をでなくするやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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