Change UI Prefabs Font for UnityEditor(NGUI UILabel)

Unity UI字体批量替换工具
这个Unity编辑器扩展脚本实现了批量替换UI预制件(Prefab)中的UILabel字体,支持调整字体大小和设置为粗体。用户可以指定新的字体文件、字体大小增量以及是否改变字体样式。工具首先查找指定目录下的所有UIPrefab,然后遍历每个Prefab中的UILabel组件进行替换操作,并保存更改。
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
/// <summary>
/// UI替换字体
/// </summary>
public class UIFontEditor : EditorWindow
{
    private static Font newFont;
    private static string uiPrefabsDir = "Assets/RawAssets/UI";
    private static int fontSizeOffset = 0;
    private static bool isFontSize=false;
    private static bool isFontBold=false;
    [MenuItem("Tools/UI/UI字体替换")]
    public static void CreateWindow()
    {
        GetWindow<UIFontEditor>("Change UI Font");
    }

    private void OnGUI()
    {
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("该工具替换UI预设UILabel字体");
        EditorGUILayout.LabelField("默认不改变字体大小和样式");
        EditorGUILayout.LabelField("默认 UI Prefabs 路径:",uiPrefabsDir);
        EditorGUILayout.Space(10);
        uiPrefabsDir = Editor
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值