using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
public class ChangeFontWindow : EditorWindow
{
[MenuItem("Tools/ChangeFont")]
public static void Open()
{
EditorWindow.GetWindow(typeof(ChangeFontWindow));
}
public Font toChange;
static Font toChangeFont;
void OnGUI()
{
toChange = (Font)EditorGUILayout.ObjectField(toChange, typeof(Font), true, GUILayout.MinWidth(100f));
toChangeFont = toChange;
if (GUILayout.Button("变变变"))
{
Change();
}
}
public static void Change()
{
Object[] labels = Selection.GetFiltered(typeof(Text), SelectionMode.Deep);
foreach (Object item in labels)
{
Text label = (Text)item;
label.font = toChangeFont;
Debug.Log(item.name + ":" + label.text);
}
}
}
【UGUI/NGUI】一键换Text/Label字体
最新推荐文章于 2021-06-25 16:23:16 发布