using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
using System.IO;
public class FontReplacer : Editor
{
private static Font s_curFont;
private static Font s_destFont;
static FontReplacer()
{
s_destFont = (Font)AssetDatabase.LoadAssetAtPath("Assets/Art/Font/fzzy.ttf", typeof(Font));
}
[MenuItem("GameObject/ReplaceFont", priority = 0)]
static void ReplaceFont()
{
Transform[] trans = Selection.transforms;
if (trans.Length == 0)
{
Debug.LogError("未选中任何替换节点");
return;
}
Transform root = trans[0];
Text[] childTexts = root.GetComponentsInChildren<Text>(true);
foreach (Text txt in childTexts)
{
// if (txt.font.name == "SOURCEHANSANSCN-REGULAR")
// {
txt.font = s_destFont;
// }
txt.lineSpacing = 1.4f;
}
AssetDatabase.SaveAssets();
Debug.Log("替换字体换成gong!");
}
}