Unity中的Label控件引用了Unity自带字体的话,打包时会报错,所以得找出来把这些字体都改成动态字体。
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using System.IO;
public class CheckUnityFont : MonoBehaviour
{
[MenuItem("Tools/Check Unity Font")]
static void Check()
{
string[] tmpFilePathArray = Directory.GetFiles(Application.dataPath, "*.*", SearchOption.AllDirectories);
EditorUtility.DisplayProgressBar("CheckUnityFont", "CheckUnityFont", 0f);
for (int i = 0; i < tmpFilePathArray.Length; i++)
{
EditorUtility.DisplayProgressBar("CheckUnityFont", "CheckUnityFont", (i * 1.0f) / tmpFilePathArray.Length);
string tmpFilePath = tmpFilePathArray[i];
//if (tmpFilePath.EndsWith(".prefab"))
//{
// StreamReader tmpStreamReader = new StreamReader(tmpFilePath);
// string tmpContent = tmpStreamReader.ReadToEnd();
// if (tmpContent.Contains("mFont: {fileID: 0}"))
// {
// Debug.LogError(tmpFilePath);
// }
//}
if (tmpFilePath.EndsWith(".prefab"))
{
StreamReader tmpStreamReader = new StreamReader(tmpFilePath);
// string tmpContent = tmpStreamReader.ReadToEnd();
while (tmpStreamReader.Peek() >= 0)
{
string tmpContent = tmpStreamReader.ReadLine();
if (tmpContent.Contains("guid: 0000000000000000d000000000000000"))
{
Debug.LogError(tmpFilePath + " tmpContent= " + tmpContent);
}
}
}
}
EditorUtility.ClearProgressBar();
}
}
网友评论