本文共 727 字,大约阅读时间需要 2 分钟。
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); } }}
转载地址:http://vbkii.baihongyu.com/