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

来源:互联网 发布:画梁图软件 编辑:程序博客网 时间:2024/05/01 20:20
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);}}}

原创粉丝点击