BMFont制作美术字体
生成 Number.fnt、Number_0.png 两个文件,将其拖入Unity 相应位置,继续下一步
箭头所指就是我们要得到的最终目标,在文本处字体使用它就可以了。
在使用 Tools -> BMFont Maker 之前得先完成以下步骤:
- using UnityEngine;
- using UnityEditor;
- public class BMFontEditor : EditorWindow
- {
- [MenuItem("Tools/BMFont Maker")]
- static public void OpenBMFontMaker()
- {
- EditorWindow.GetWindow<BMFontEditor>(false, "BMFont Maker", true).Show();
- }
- [SerializeField]
- private Font targetFont;
- [SerializeField]
- private TextAsset fntData;
- [SerializeField]
- private Material fontMaterial;
- [SerializeField]
- private Texture2D fontTexture;
- private BMFont bmFont = new BMFont();
- public BMFontEditor()
- {
- }
- void OnGUI()
- {
- targetFont = EditorGUILayout.ObjectField("Target Font", targetFont, typeof(Font), false) as Font;
- fntData = EditorGUILayout.ObjectField("Fnt Data", fntData, typeof(TextAsset), false) as TextAsset;
- fontMaterial = EditorGUILayout.ObjectField("Font Material", fontMaterial, typeof(Material), false) as Material;
- fontTexture = EditorGUILayout.ObjectField("Font Texture", fontTexture, typeof(Texture2D), false) as Texture2D;
- if (GUILayout.Button("Create BMFont"))
- {
- BMFontReader.Load(bmFont, fntData.name, fntData.bytes); //借用NGUI封装的读取类
- CharacterInfo[] characterInfo = new CharacterInfo[bmFont.glyphs.Count];
- for (int i = 0; i < bmFont.glyphs.Count; i++)
- {
- BMGlyph bmInfo = bmFont.glyphs[i];
- CharacterInfo info = new CharacterInfo();
- info.index = bmInfo.index;
- info.uv.x = (float)bmInfo.x / (float)bmFont.texWidth;
- info.uv.y = 1 - (float)bmInfo.y / (float)bmFont.texHeight;
- info.uv.width = (float)bmInfo.width / (float)bmFont.texWidth;
- info.uv.height = -1f * (float)bmInfo.height / (float)bmFont.texHeight;
- info.vert.x = 0;
- info.vert.y = -(float)bmInfo.height;
- info.vert.width = (float)bmInfo.width;
- info.vert.height = (float)bmInfo.height;
- info.width = (float)bmInfo.advance;
- characterInfo[i] = info;
- }
- targetFont.characterInfo = characterInfo;
- if (fontMaterial)
- {
- fontMaterial.mainTexture = fontTexture;
- }
- targetFont.material = fontMaterial;
- fontMaterial.shader = Shader.Find("UI/Default");//这一行很关键,如果用standard的shader,放到Android手机上,第一次加载会很慢
- Debug.Log("Create Font <" + targetFont.name + "> Success");
- Close();
- }
- }
- }
将这个类放入工程中,这样在 Tools 中才可以找到 BMFont Maker,它的作用是赋予字体的详细信息,由于它是借助 NGUI 来实现的工具,所以得加上 NGUI 中的以下类:
BMFont制作美术字体的更多相关文章
- Unity3d之-使用BMFont制作美术字体
一.需求 游戏开发中经常遇到需要以美术字(而非字库)做数字显示的情况,通常美术会提供一组包含单个数字(也会有其它字符)的图片,可能是一张整图,也可能是每个数字分开的散图. 在此我以一张整图这种情况为例 ...
- Unity3D中使用BMFont制作图片字体 (NGUI版)
[旧博客转移 - 发布于2015年9月10日 16:07] 有时美术会出这种图片格式的文字,NGUI提供了UIFont来支持BMFont导出的图片字体 BMFont原理其实很简单,首先会把文字小图拼成 ...
- Unity教程之-UGUI美术字体的制作与使用
文章转载自:http://www.unity.5helpyou.com/3211.html 游戏制作中,经常需要使用各种花哨的文字或者数字,而字体库往往不能达到我们需要的效果,因此需要一种用图片替代文 ...
- Unity 使用BMFont制作字体
参考链接:http://blog.csdn.net/huang9012/article/details/32333913,作者:CSDN huang9012 NGUI版本:3.6.5 要自己制作字体, ...
- 详解利用ShoeBox制作位图字体
http://childhood.logdown.com/posts/190580/-details-using-shoebox-produce-bitmap-fonts?utm_source=tui ...
- bmp制作自定义字体(cocostudio使用)
工具需求:bmpfont 1.步骤 (1)制作 * 把自己的字体放到一个txt文件中,写个脚本抽离出来, 重复了没有关系 * Edit->Select chars from fils(注意:Ed ...
- 如何制作图标字体(如何将svg转换为css可用的图标字体)
转自: 如何制作图标字体(如何将svg转换为css可用的图标字体) 具体描述 在项目开发当中,我们常常遇到需要将获取到的svg转换为,css可用的图标字体,那么具体该如何进行操作呢 具体操作 登录ic ...
- 使用bmfont制作字体
本地显示正常 将制作好的字体上传 别人用不好使 制作完场景没ctrl+s 保存 ctrl+s保存之后生成另外的文件
- 如何用Unity制作自定义字体——Custom Font
一.效果图 二.步骤 将美术做好的字体分块导入BMFont,使用BMFont工具生成艺术字库: 将上面的数据导入unity资源目录下:*.fnt文件中记录每个文字的状态信息: 导入*.png图片并设置 ...
随机推荐
- 解决 Ionic 浏览器跨域问题
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Contro ...
- img没有src属性时自动出现边框
当img没有接收到src属性的时候会自动出现边框,border:0/none都不管用的情况下 解决方法 一行css 可以解决 img[src=""],img:not([src]){ ...
- detailFormatter bootstrapTable
detailView : true,//会导致表格最开头多出一列 detailFormatter :function(index, row, element){ var image = '<di ...
- rem+media+jquery布局结局方案
; ; } ? ; + 'px'; } document.addEventListener('DOMContentLoaded', callback); window.addEventListener ...
- Qt5.11.1安装与VS2017配置
Qt5.11.1安装与VS2017配置 转 https://blog.csdn.net/gaojixu/article/details/82185694 文章目录 Qt5.11.1安装与VS2017配 ...
- 移动端滑屏全应用【四】移动端动画贞动画函数mTween封装
首先此函数是基于大家都知道的Tween动画算法的,在此基础上使用了三中讲到的兼容版动画贞,可以使动画变得更流畅. 1. 首先要记得引入Tween.js 2. 引入mTween.js 3. 调用 * m ...
- Myeclipse10.0版下载
链接:http://pan.baidu.com/s/1kVl1kSf 密码:p6yr 主界面框图
- 蓝桥杯 ——无重复组合——C++
问题描述: 求任意长度的(ABCD.....)全部n=0,1,2 ....组合情况(n小于等于串的长度) 解决思路: 如果串的长度固定,n的值固定循环嵌套 在这里以深度优先形成一棵树,如下图: 源代码 ...
- C# 结合html5 批量上传文件和图片预览
html5 新特性 <input id="imgsf" type="file" name="imgsf" multiple /> ...
- git解决Could not execute editor
我是安装k-vim后出现了这个问题,可能是vim的某些插件引起的 配置git的编辑器可解决: git config --global core.editor "/usr/bin/vim&qu ...