unity UGUI生成字体小工具

代码比较简单,主要是项目频繁的遇到数字字体,为了方便写了个小工具,直接导入项目就可以使用。

要求美工必须把字体均匀大小的整齐排序好。

例如:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEditor;

public class CustomFontCreator : EditorWindow
{
    float m_TileWidth;
    float m_TileHeight;
    float m_TileMaxY;
    string m_Key = "0123456789";
    bool m_UseFontTxt;

    [MenuItem("Tools/CustomFontCreator")]
    static void Init()
    {
        var window = (CustomFontCreator)EditorWindow.GetWindow(typeof(CustomFontCreator));
        window.Show();
    }

    void OnGUI()
    {
        var tex = Selection.activeObject as Texture;
        if (tex == null)
        {
            EditorGUILayout.LabelField("请选择一张字体贴图");
        }
        else
        {   
            var texWidth = tex.width;
            var texHeith = tex.height;
            EditorGUILayout.BeginVertical();
            if (!m_UseFontTxt)
            {
                m_Key = EditorGUILayout.TextField("Keys", m_Key);

                if (m_TileWidth == 0 && m_Key.Length > 0)
                {
                    m_TileWidth = texWidth / m_Key.Length;
                }
                if (m_TileHeight == 0)
                {
                    m_TileHeight = texHeith;
                }

       
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值