最近遇到一个需求,就是我们在做完一个场景后,美工感觉字体不好看,效果不是很好,想要换一种字体。UGUI的界面已经搭完,如果要一个一个Text寻找,工作量将是巨大。而且作为程序人员是不会容忍自己做这些机械工作的,所以,有必要写一个脚本来让场景中的Text字体变换了。
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.UI;
public class ChangeFontWindow : EditorWindow
{
[MenuItem("Tools/更换字体")]
public static void Open()
{
EditorWindow.GetWindow(typeof(ChangeFontWindow));
}
Font toChange;
static Font toChangeFont;
FontStyle toFontStyle;
static FontStyle toChangeFontStyle;
void OnGUI()
{
toChange = (Font)EditorGUILayout.ObjectField(toChange, typeof(Font), true, GUILayout.MinWidth(100f));
toChangeFont = toChange;
toFontStyle = (FontStyle)Edi