Unity批量替换文字字体自制工具

本文介绍了一款自制工具,用于在Unity中批量替换Text组件的字体。该工具遍历指定文件夹下的预制体,修改Text组件的字体,并提供字体风格的替换功能。通过工具面板进行操作,简化了游戏开发中的字体管理。
摘要由CSDN通过智能技术生成

本工具就如标题一样,是用来批量替换unity中Text组件中的字体的工具。

原理就是查找文件夹下的所有预制体,批量修改预制体中存在的Text组件的字体数据。有做一个指定某种字体替换到另外一种字体的功能,这里我还拓展了字体风格的修改。

工具面板如下:

话不多说,代码如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using System.IO;
using System.Linq;
using System;
using Unity.Linq;
/// <summary>
/// Text字体修改工具
/// </summary>
public class FontChangeTool : EditorWindow
{
    private string path;
    List<GameObject> prefabList = new List<GameObject>();   
    string[] assetsPaths = new string[0];
    List<bool> flagList ;
    Vector2 scallPos;
     
    static FontChangeTool window; 
    bool isSpecifyFontReplace;//是否指定字体更换
    Font oldFont;
    Font toChange;
    static Font toChangeFont;
    bool isFontStyleReplace;//是否需要替换字体风格
    FontStyle toFontStyle;
    static FontStyle toChangeFontStyle;


    private void OnGUI()
    {
        RefreshUI();
    }

    [MenuItem("Tools/FontChangeTool/字体设置")]
    public static void InitFont()
    {
        window = (FontChangeTool)GetWindow(typeof(FontChangeTool));
        window.titleContent.text = "字体设置";
        window.position = new Rect(PlayerSettings.defaultScreenWidth /
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值