暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TMP_PreBuildProcessor.cs 1.1KB

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using UnityEditor;
  3. using UnityEditor.Build;
  4. using UnityEditor.Build.Reporting;
  5. namespace TMPro
  6. {
  7. public class TMP_PreBuildProcessor : IPreprocessBuildWithReport
  8. {
  9. public int callbackOrder { get { return 0; } }
  10. public void OnPreprocessBuild(BuildReport report)
  11. {
  12. // Find all font assets in the project
  13. string searchPattern = "t:TMP_FontAsset";
  14. string[] fontAssetGUIDs = AssetDatabase.FindAssets(searchPattern);
  15. for (int i = 0; i < fontAssetGUIDs.Length; i++)
  16. {
  17. string fontAssetPath = AssetDatabase.GUIDToAssetPath(fontAssetGUIDs[i]);
  18. TMP_FontAsset fontAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(fontAssetPath);
  19. if (fontAsset != null && (fontAsset.atlasPopulationMode == AtlasPopulationMode.Dynamic || fontAsset.atlasPopulationMode == AtlasPopulationMode.DynamicOS) && fontAsset.clearDynamicDataOnBuild && fontAsset.atlasTexture.width != 0)
  20. {
  21. fontAsset.ClearCharacterAndGlyphTablesInternal();
  22. }
  23. }
  24. }
  25. }
  26. }