unity 发光字体_Unity UGUI 使用艺术字体
道具准备
字体制作
菜单栏上单击 Edit -> Open Image Manager。 再单击 Image -> Import image,把你要做成位图字体的图片依次导入进来。如果是中文字体可以查看该汉字
导出设置选择 png 和 txt 格式。然后导出字体即可
把 png 和 fnt 字体拖入unity 后 创建一个材质和自定义字体,然后做好关联。
选择fnt 字体 右键 选择 Create/ CreateBMFont选线,就会把 fnt的信息自动加入倒 fontseting 格式的文件中。
CreateFontEditor.cs 源码using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
public class CreateFontEditor : Editor
{
[MenuItem("Assets/Create/CreateBMFont")]
static void CreateFont()
{
Object obj = Selection.activeObject;
string fntPath = AssetDatabase.GetAssetPath(obj);
Debug.Log("#####" + fntPath);
if (fntPath.IndexOf(".fnt") == -1)
{
Debug.Log("不是字体文件");
return;
}
string customFontPath = fntPath.Replace(".fnt", ".fontsettings");
if (!File.Exists(customFontPath))
{
Debug.Log("导入的自定义字体文件不存在");
return;
}
Debug.Log(fntPath);
StreamReader reader = new StreamReader(new FileStream(fntPath, FileMode.Open));
List charList = new List();
Regex reg = new Regex(@"char id=(?\d+)\s+x=(?\d+)\s+y=(?\d+)\s+width=(?\d+)\s+height=(?\d+)\s+xoffset=(?\d+)\s+yoffset=(?\d+)\s+xadvance=(?\d+)\s+");
string line = reader.ReadLine();
int lineHeight = 0;
int texWidth = 1;
int texHeight = 1;
while (line != null)
{
if (line.IndexOf("char id=") != -1)
{
Match match = reg.Match(line);
if (match != Match.Empty)
{
var id = System.Convert.ToInt32(match.Groups["id"].Value);
var x = System.Convert.ToInt32(match.Groups["x"].Value);
var y = System.Convert.ToInt32(match.Groups["y"].Value);
var width = System.Convert.ToInt32(match.Groups["width"].Value);
var height = System.Convert.ToInt32(match.Groups["height"].Value);
var xoffset = System.Convert.ToInt32(match.Groups["xoffset"].Value);
var yoffset = System.Convert.ToInt32(match.Groups["yoffset"].Value);
var xadvance = System.Convert.ToInt32(match.Groups["xadvance"].Value);
CharacterInfo info = new CharacterInfo();
info.index = id;
float uvx = 1f * x / texWidth;
float uvy = 1 - (1f * y / texHeight);
float uvw = 1f * width / texWidth;
float uvh = -1f * height / texHeight;
info.uvBottomLeft = new Vector2(uvx, uvy);
info.uvBottomRight = new Vector2(uvx + uvw, uvy);
info.uvTopLeft = new Vector2(uvx, uvy + uvh);
info.uvTopRight = new Vector2(uvx + uvw, uvy + uvh);
info.minX = xoffset;
info.minY = yoffset + height / 2;
info.glyphWidth = width;
info.glyphHeight = -height;
info.advance = xadvance;
charList.Add(info);
}
}
else if (line.IndexOf("scaleW=") != -1)
{
Regex reg2 = new Regex(@"common lineHeight=(?\d+)\s+.*scaleW=(?\d+)\s+scaleH=(?\d+)");
Match match = reg2.Match(line);
if (match != Match.Empty)
{
lineHeight = System.Convert.ToInt32(match.Groups["lineHeight"].Value);
texWidth = System.Convert.ToInt32(match.Groups["scaleW"].Value);
texHeight = System.Convert.ToInt32(match.Groups["scaleH"].Value);
}
}
line = reader.ReadLine();
}
Font customFont = AssetDatabase.LoadAssetAtPath(customFontPath);
customFont.characterInfo = charList.ToArray();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
Debug.Log("处理完成: " + customFont);
}
}
unity 发光字体_Unity UGUI 使用艺术字体相关推荐
- 如何转换字体为手写体?艺术字体在线生成器怎么用?
艺术字体其实是一个非常笼统的概念,艺术字是对文案的美化,也能够突出文案,在进行图片设计的时候经常会用到各种艺术字体,好看的艺术字体的作用并不比一张设计图的效果差,那么应该怎样将字体转化成好看的艺术字体 ...
- 【u3d泰斗破坏神】08 --- UGUI 制作艺术字体
一.工具准备 BMFont:http://www.angelcode.com/products/bmfont/ UGUIFontEditor: 链接:http://pan.baidu.com/s/1s ...
- html如何制作艺术字体,设计华丽金沙艺术字体图片的PS教程
这是网上极为流行的文字效果,非常华丽和细腻:虽然制作不难,不过光影部分的渲染要求极高,不仅要把沙子的颗粒感和颜色都刻画出来:同时还需要在边缘增加高光,底部还需要增加打散的细小颗粒.本人通过不断摸索,找 ...
- 【游戏开发实战】可爱的动物数字,教你在Unity中自制UGUI艺术字体(位图字体)(Bitmap Font Generator)
文章目录 一.前言 二.最终效果 三.Bitmap Font Generator制作字体 1.准备字体图片 2.下载Bitmap Font Generator 3.bmfont64.exe导入图片 4 ...
- unity 发光字体_Unity中字体的一些知识
Unity中的字体常用的有:内置字体,外部导入的字体,自定义的字体. 1,内置字体. 内置字体一般是指unity自带的字体,Windows下unity自带字体为Arial,如果游戏中使用Arial字体 ...
- unity怎么在文本中修改字体_[专栏作家]UGUI中CustomFont字体使用与制作
原标题:[专栏作家]UGUI中CustomFont字体使用与制作 前言: 如何在UGUI中使用自定义的数字图片.在开发过程中,美术同学会给出类似艺术数字图片如下图: 那在UGUI系统中如何使用呢? U ...
- 一键生成UGUI艺术字体
原文地址 https://blog.csdn.net/qq_28221881/article/details/75315326 需要注意的是:字体文件的名字要对应相应的艺术字体,比如 1->1的 ...
- 【UGUI】美术字体的制作与使用
原文:http://www.unity.5helpyou.com/3211.html 游戏制作中,经常需要使用各种花哨的文字或者数字,而字体库往往不能达到我们需要的效果,因此需要一种用图片替代文字的功 ...
- UGUI运用美术字体
UGUI运用美术字体 在游戏的制作中,美术字的运用是美化游戏的常用手段.比如普攻,暴击打出的战斗飘字就常常利用不同的美术字来做出区别.那么在Unity中如何把美术字运用起来呢?且看下文: 1.道具准备 ...
最新文章
- linux epoll用法
- 维基百科联手谷歌翻译,结果“惨不忍睹”!
- 在MATPLOTLIB中加入汉字显示
- python调用dll依赖项
- 洛谷——P2118 比例简化
- 1023 组个最小数 (20 分)(c语言)
- Linux设备驱动之Kobject、Kset
- Visual Studio调试之断点基础篇
- [译]5 Mac OS X RSS Readers Worth Giving a Shot
- 五、QPushButton按钮和QLineEdit控件操作
- Ado.Net 实体类、数据连接类、数据访问类
- CENTOS 6.6初始化SHELL脚本
- html取消重复,减少重复的HTML代码
- 文字识别(三)--文字定位与切割
- POJ 3378 树状数组+DP+离散化+高精度
- 601. 体育馆的人流量
- 第十二周助教心得体会
- The Thirty-eighth Of Word-Day
- 如何利用cmd打开资源管理器
- OSError: Could not find kaggle.json. Make sure it‘s located in /home/user/.kaggle.
热门文章
- Elasticsearch:使用 fuzziness 来进行搜索
- 【大数据面试】瞎说宝典
- 02_功分器设计及联合式EM仿真
- 友盟集成小米华为(快速集成和厂商通道集成)
- android华为和小米,都是用安卓,为什么用小米和华为体验完全不一样?网友的评论扎心了!...
- oracle日志在哪里看,Oracle日志文件管理与查看
- 基于c#的区块链编程_C#编程之C#区块链零基础入门,学习路线图
- new和malloc区别和malloc详解
- 数据分析的意义和方法
- 深度强化学习 - 无人驾驶自行车