在项目开发过程中可能会遇到更改字体的需求,如果手动逐一更改实在是太麻烦,所以我们需要自动化,一键能解决的问题绝不点击两次
效果过下
源码如下
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEngine.UI;
public class ChangeFontWindow : EditorWindow
{
[MenuItem("Tools/换字体")]
public static void Open()
{
/*第一个参数窗口类型,决定窗口操作逻辑
* 第二个参数确定是否为浮动窗口,选择false可有停靠效果
* 第三个参数 显示窗口的标题
* 第四个 目前不知道什么意思
*/
EditorWindow.GetWindow(typeof(ChangeFontWindow), true);
}
//public Font toChange = new Font("Arial");
public Font toChange;
static Font toChangeFont;
void OnGUI()
{
toChange = (Font)EditorGUILayout.ObjectField("选择需要更换的字体",toChange, typeof(Font), true, GUILayout.MinWidt