您的位置:首页 > 产品设计 > UI/UE

【UGUI/NGUI】一键换Text/Label字体

2017-09-22 13:06 393 查看
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);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: