Singularity/Library/PackageCache/com.unity.textmeshpro@3.0.8/Scripts/Editor/TMP_PreBuildProcessor.cs

32 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-05-06 14:45:45 -04:00
using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
namespace TMPro
{
public class TMP_PreBuildProcessor : IPreprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
public void OnPreprocessBuild(BuildReport report)
{
// Find all font assets in the project
string searchPattern = "t:TMP_FontAsset";
string[] fontAssetGUIDs = AssetDatabase.FindAssets(searchPattern);
for (int i = 0; i < fontAssetGUIDs.Length; i++)
{
string fontAssetPath = AssetDatabase.GUIDToAssetPath(fontAssetGUIDs[i]);
TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(fontAssetPath);
if (fontAsset != null && fontAsset.atlasPopulationMode == AtlasPopulationMode.Dynamic && fontAsset.clearDynamicDataOnBuild && fontAsset.atlasTexture.width != 0)
{
//Debug.Log("Clearing [" + fontAsset.name + "] dynamic font asset data.");
fontAsset.ClearFontAssetDataInternal();
}
}
}
}
}