中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

天河企業(yè)網(wǎng)站建設(shè)青島網(wǎng)站建設(shè)有限公司

天河企業(yè)網(wǎng)站建設(shè),青島網(wǎng)站建設(shè)有限公司,房產(chǎn)中介網(wǎng)站,如何讓網(wǎng)站速度快下載Bitmap Font Generator BMFont - AngelCode.com 解壓后不用安裝直接雙擊使用 提前設(shè)置 1、設(shè)置Bit depth為32 Options->Export options 2、清空所選字符 因為我們將在后邊導(dǎo)入需要的字符。 Edit->Select all chars 先選擇所有字符 Edit->Clear all chars i…

下載Bitmap Font Generator

BMFont - AngelCode.com

解壓后不用安裝直接雙擊使用

提前設(shè)置

1、設(shè)置Bit depth為32

Options->Export options

2、清空所選字符

因為我們將在后邊導(dǎo)入需要的字符。

Edit->Select all chars? 先選擇所有字符

Edit->Clear all chars in font? 再清空所有字符

配置字符

1、打開Open Image Manager

Edit->Open Image Manager

2、配置字符和對應(yīng)的字符圖片

先準(zhǔn)備這些字符的ASCII碼

可以通過在線工具查詢:ASCII編碼轉(zhuǎn)換,ASCII碼在線查詢工具

字符

ASCII碼

0

48

1

49

2

50

3

51

4

52

5

53

6

54

7

55

8

56

9

57

.

46

+

43

-

45

K

75

M

77

G

71

點擊Image->Import image,開始配置

返回主界面,查看標(biāo)有小亮點的字符為已配置成功的字符

導(dǎo)出文件

導(dǎo)出前可以預(yù)覽一下 Options->Visualize

直接導(dǎo)出

Options->Save bitmap font as....

導(dǎo)出成功

導(dǎo)入Unity使用

創(chuàng)建下面兩個腳本,將其放到Editor文件夾下

using UnityEngine;
using UnityEditor;
using System;
using System.IO;public class BFImporter : AssetPostprocessor
{static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths){foreach (string str in importedAssets){DoImportBitmapFont(str);}foreach (string str in deletedAssets){DelBitmapFont(str);}for (var i = 0; i < movedAssets.Length; i++){MoveBitmapFont(movedFromAssetPaths[i], movedAssets[i]);}}public static bool IsFnt(string path){return path.EndsWith(".fnt", StringComparison.OrdinalIgnoreCase);}public static void DoImportBitmapFont(string fntPath){if (!IsFnt(fntPath)) return;TextAsset fnt = AssetDatabase.LoadMainAssetAtPath(fntPath) as TextAsset;string text = fnt.text;FntParse parse = FntParse.GetFntParse(ref text);if (parse == null) return;string fntName = Path.GetFileNameWithoutExtension(fntPath);string rootPath = Path.GetDirectoryName(fntPath);string fontPath = string.Format("{0}/{1}.fontsettings", rootPath, fntName);Texture2D[] textures = DoImportTextures(parse, rootPath, fnt);if (textures.Length > 1){Debug.LogError(fntPath + " has more than one texture!");}Font font = AssetDatabase.LoadMainAssetAtPath(fontPath) as Font;if (font == null){font = new Font();AssetDatabase.CreateAsset(font, fontPath);AssetDatabase.WriteImportSettingsIfDirty(fontPath);AssetDatabase.ImportAsset(fontPath);}Material material = AssetDatabase.LoadAssetAtPath(fontPath, typeof(Material)) as Material;if (material == null){material = new Material(Shader.Find("UI/Default"));material.name = "Font Material";AssetDatabase.AddObjectToAsset(material, fontPath);// unity 5.4+ cannot refresh it immediately, must import itAssetDatabase.ImportAsset(fontPath);}font.material = material;material.mainTexture = textures[0];font.characterInfo = parse.charInfos;SerializedObject so = new SerializedObject(font);so.Update();so.FindProperty("m_FontSize").floatValue = Mathf.Abs(parse.fontSize);so.FindProperty("m_LineSpacing").floatValue = parse.lineHeight;so.FindProperty("m_Ascent").floatValue = parse.lineBaseHeight;SerializedProperty prop = so.FindProperty("m_Descent");if (prop != null)prop.floatValue = parse.lineBaseHeight - parse.lineHeight;UpdateKernings(so, parse.kernings);so.ApplyModifiedProperties();so.SetIsDifferentCacheDirty();AssetDatabase.DeleteAsset(fntPath);AssetDatabase.SaveAssets();// unity 5.5 can not load custom fontReloadFont(fontPath);}private static Texture2D[] DoImportTextures(FntParse parse, string rootPath, TextAsset fnt){int len = parse.textureNames.Length;Texture2D[] textures = new Texture2D[len];for (int i = 0; i < len; i++){string texPath = string.Format("{0}/{1}", rootPath, parse.textureNames[i]);Texture2D texture = AssetDatabase.LoadMainAssetAtPath(texPath) as Texture2D;if (texture == null){Debug.LogErrorFormat(fnt, "{0}: not found '{1}'.", typeof(BFImporter), texPath);return textures;}TextureImporter texImporter = AssetImporter.GetAtPath(texPath) as TextureImporter;texImporter.textureType = TextureImporterType.GUI;texImporter.mipmapEnabled = false;texImporter.SaveAndReimport();textures[i] = texture;}return textures;}private static void UpdateKernings(SerializedObject so, Kerning[] kernings){int len = kernings != null ? kernings.Length : 0;SerializedProperty kerningsProp = so.FindProperty("m_KerningValues");if (len == 0){kerningsProp.ClearArray();return;}int propLen = kerningsProp.arraySize;for (int i = 0; i < len; i++){if (propLen <= i){kerningsProp.InsertArrayElementAtIndex(i);}SerializedProperty kerningProp = kerningsProp.GetArrayElementAtIndex(i);kerningProp.FindPropertyRelative("second").floatValue = kernings[i].amount;SerializedProperty pairProp = kerningProp.FindPropertyRelative("first");pairProp.Next(true);pairProp.intValue = kernings[i].first;pairProp.Next(false);pairProp.intValue = kernings[i].second;}for (int i = propLen - 1; i >= len; i--){kerningsProp.DeleteArrayElementAtIndex(i);}}private static void DelBitmapFont(string fntPath){if (!IsFnt(fntPath)) return;string fontPath = fntPath.Substring(0, fntPath.Length - 4) + ".fontsettings";AssetDatabase.DeleteAsset(fontPath);}private static void MoveBitmapFont(string oldFntPath, string nowFntPath){if (!IsFnt(nowFntPath)) return;string oldFontPath = oldFntPath.Substring(0, oldFntPath.Length - 4) + ".fontsettings";string nowFontPath = nowFntPath.Substring(0, nowFntPath.Length - 4) + ".fontsettings";AssetDatabase.MoveAsset(oldFontPath, nowFontPath);}// new font can not display via Text in unity 5.5// must import import itprivate static void ReloadFont(string fontPath){var tmpPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());AssetDatabase.ExportPackage(fontPath, tmpPath);AssetDatabase.DeleteAsset(fontPath);var startTime = DateTime.Now;EditorApplication.CallbackFunction func = null;func = () =>{TimeSpan dalt = DateTime.Now - startTime;if (dalt.TotalSeconds >= 0.1){EditorApplication.update -= func;AssetDatabase.ImportPackage(tmpPath, false);File.Delete(tmpPath);}};EditorApplication.update += func;}
}
using UnityEngine;
using System.Xml;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;public struct Kerning
{public int first;public int second;public int amount;
}public class FntParse
{public int textureWidth;public int textureHeight;public string[] textureNames;public string fontName;public int fontSize;public int lineHeight;public int lineBaseHeight;public CharacterInfo[] charInfos { get; private set; }public Kerning[] kernings { get; private set; }public static FntParse GetFntParse(ref string text){FntParse parse = null;if (text.StartsWith("info")){parse = new FntParse();parse.DoTextParse(ref text);}else if (text.StartsWith("<")){parse = new FntParse();parse.DoXMLPase(ref text);}return parse;}#region xmlpublic void DoXMLPase(ref string content){XmlDocument xml = new XmlDocument();xml.LoadXml(content);XmlNode info = xml.GetElementsByTagName("info")[0];XmlNode common = xml.GetElementsByTagName("common")[0];XmlNodeList pages = xml.GetElementsByTagName("pages")[0].ChildNodes;XmlNodeList chars = xml.GetElementsByTagName("chars")[0].ChildNodes;fontName = info.Attributes.GetNamedItem("face").InnerText;fontSize = ToInt(info, "size");lineHeight = ToInt(common, "lineHeight");lineBaseHeight = ToInt(common, "base");textureWidth = ToInt(common, "scaleW");textureHeight = ToInt(common, "scaleH");int pageNum = ToInt(common, "pages");textureNames = new string[pageNum];for (int i = 0; i < pageNum; i++){XmlNode page = pages[i];int pageId = ToInt(page, "id");textureNames[pageId] = page.Attributes.GetNamedItem("file").InnerText;}charInfos = new CharacterInfo[chars.Count];for (int i = 0; i < chars.Count; i++){XmlNode charNode = chars[i];charInfos[i] = CreateCharInfo(ToInt(charNode, "id"),ToInt(charNode, "x"),ToInt(charNode, "y"),ToInt(charNode, "width"),ToInt(charNode, "height"),ToInt(charNode, "xoffset"),ToInt(charNode, "yoffset"),ToInt(charNode, "xadvance"),ToInt(charNode, "page"));}// kerningsXmlNode kerningsNode = xml.GetElementsByTagName("kernings")[0];if (kerningsNode != null && kerningsNode.HasChildNodes){XmlNodeList kerns = kerningsNode.ChildNodes;kernings = new Kerning[kerns.Count];for (int i = 0; i < kerns.Count; i++){XmlNode kerningNode = kerns[i];kernings[i] = new Kerning();kernings[i].first = ToInt(kerningNode, "first");kernings[i].second = ToInt(kerningNode, "second");kernings[i].amount = ToInt(kerningNode, "amount");}}}private static int ToInt(XmlNode node, string name){return int.Parse(node.Attributes.GetNamedItem(name).InnerText);}#endregion#region textprivate Regex pattern;public void DoTextParse(ref string content){// letter=" "       // \S+=".+?"// letter="x"       // \S+=".+?"// letter="""       // \S+=".+?"// letter=""        // \S+// char             // \S+pattern = new Regex(@"\S+="".+?""|\S+");string[] lines = content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);ReadTextInfo(ref lines[0]);ReadTextCommon(ref lines[1]);for (int j = 0; j < textureNames.Length; j++){ReadTextPage(ref lines[j + 2]);}// don't use count of chars, count is incorrect if has space //ReadTextCharCount(ref lines[3]);List<CharacterInfo> list = new List<CharacterInfo>();int i = 2 + textureNames.Length;int l = lines.Length;for (; i < l; i++){if (!ReadTextChar(i - 4, ref lines[i], ref list))break;}charInfos = list.ToArray();// skip empty linefor (; i < l; i++){if (lines[i].Length > 0)break;}// kerningsif (i < l){int count = 0;if (ReadTextCount(ref lines[i++], out count)){int start = i;kernings = new Kerning[count];for (; i < l; i++){if (!ReadTextKerning(i - start, ref lines[i], ref list))break;}};}}private void ReadTextInfo(ref string line){string[] keys;string[] values;SplitParts(line, out keys, out values);for (int i = keys.Length - 1; i >= 0; i--){switch (keys[i]){case "face": fontName = values[i]; break;case "size": fontSize = int.Parse(values[i]); break;}}}private void ReadTextCommon(ref string line){string[] keys;string[] values;SplitParts(line, out keys, out values);for (int i = keys.Length - 1; i >= 0; i--){switch (keys[i]){case "lineHeight": lineHeight = int.Parse(values[i]); break;case "base": lineBaseHeight = int.Parse(values[i]); break;case "scaleW": textureWidth = int.Parse(values[i]); break;case "scaleH": textureHeight = int.Parse(values[i]); break;case "pages": textureNames = new string[int.Parse(values[i])]; break;}}}private void ReadTextPage(ref string line){string[] keys;string[] values;SplitParts(line, out keys, out values);string textureName = null;int pageId = -1;for (int i = keys.Length - 1; i >= 0; i--){switch (keys[i]){case "file": textureName = values[i]; break;case "id": pageId = int.Parse(values[i]); break;}}textureNames[pageId] = textureName;}private bool ReadTextCount(ref string line, out int count){string[] keys;string[] values;SplitParts(line, out keys, out values);count = 0;for (int i = keys.Length - 1; i >= 0; i--){switch (keys[i]){case "count":count = int.Parse(values[i]);return true;}}return false;}private bool ReadTextChar(int idx, ref string line, ref List<CharacterInfo> list){if (!line.StartsWith("char")) return false;string[] keys;string[] values;SplitParts(line, out keys, out values);int id = 0, x = 0, y = 0, w = 0, h = 0, xo = 0, yo = 0, xadvance = 0;for (int i = keys.Length - 1; i >= 0; i--){switch (keys[i]){case "id": id = int.Parse(values[i]); break;case "x": x = int.Parse(values[i]); break;case "y": y = int.Parse(values[i]); break;case "width": w = int.Parse(values[i]); break;case "height": h = int.Parse(values[i]); break;case "xoffset": xo = int.Parse(values[i]); break;case "yoffset": yo = int.Parse(values[i]); break;case "xadvance": xadvance = int.Parse(values[i]); break;}}list.Add(CreateCharInfo(id, x, y, w, h, xo, yo, xadvance));return true;}private bool ReadTextKerning(int idx, ref string line, ref List<CharacterInfo> list){if (!line.StartsWith("kerning")) return false;string[] keys;string[] values;SplitParts(line, out keys, out values);Kerning kerning = new Kerning();for (int i = keys.Length - 1; i >= 0; i--){switch (keys[i]){case "first": kerning.first = int.Parse(values[i]); break;case "second": kerning.second = int.Parse(values[i]); break;case "amount": kerning.amount = int.Parse(values[i]); break;}}kernings[idx] = kerning;return true;}private bool SplitParts(string line, out string[] keys, out string[] values){MatchCollection parts = pattern.Matches(line);int count = parts.Count;keys = new string[count - 1];values = new string[count - 1];for (int i = count - 2; i >= 0; i--){string part = parts[i + 1].Value;int pos = part.IndexOf('=');keys[i] = part.Substring(0, pos);values[i] = part.Substring(pos + 1).Trim('"');}return true;}#endregionprivate CharacterInfo CreateCharInfo(int id, int x, int y, int w, int h, int xo, int yo, int xadvance, int page = 0){Rect uv = new Rect();uv.x = (float)x / textureWidth + page;uv.y = (float)y / textureHeight;uv.width = (float)w / textureWidth;uv.height = (float)h / textureHeight;uv.y = 1f - uv.y - uv.height;Rect vert = new Rect();vert.x = xo;
#if UNITY_5_0 || UNITY_5_1 || UNITY_5_2// unity 5.0 can not support baseline for vert.y = yo;
#elsevert.y = yo - lineBaseHeight;
#endifvert.width = w;vert.height = h;vert.y = -vert.y;vert.height = -vert.height;CharacterInfo charInfo = new CharacterInfo();charInfo.index = id;#if UNITY_5_3_OR_NEWER || UNITY_5_3 || UNITY_5_2charInfo.uvBottomLeft = new Vector2(uv.xMin, uv.yMin);charInfo.uvBottomRight = new Vector2(uv.xMax, uv.yMin);charInfo.uvTopLeft = new Vector2(uv.xMin, uv.yMax);charInfo.uvTopRight = new Vector2(uv.xMax, uv.yMax);charInfo.minX = (int)vert.xMin;charInfo.maxX = (int)vert.xMax;charInfo.minY = (int)vert.yMax;charInfo.maxY = (int)vert.yMin;charInfo.bearing = (int)vert.x;charInfo.advance = xadvance;
#else
#pragma warning disable 618charInfo.uv = uv;charInfo.vert = vert;charInfo.width = xadvance;
#pragma warning restore 618
#endifreturn charInfo;}
}

將這兩個文件直接拖入Unity中,系統(tǒng)自動生成字體文件

直接使用

http://www.risenshineclean.com/news/41553.html

相關(guān)文章:

  • 群暉wordpress中文鄭州網(wǎng)站關(guān)鍵詞優(yōu)化公司哪家好
  • 深圳市龍華區(qū)房價萬能優(yōu)化大師下載
  • 東營網(wǎng)站建設(shè)收益高恩城seo的網(wǎng)站
  • 做淘寶的網(wǎng)站企業(yè)網(wǎng)站營銷的優(yōu)缺點
  • 唐山設(shè)計網(wǎng)站公司達內(nèi)教育
  • 明星做av網(wǎng)站百度郵箱注冊入口
  • 廣州市企業(yè)網(wǎng)站建設(shè)企業(yè)網(wǎng)絡(luò)推廣都是收費
  • 學(xué)校網(wǎng)站怎么做推廣千博企業(yè)網(wǎng)站管理系統(tǒng)
  • 鄭州移動網(wǎng)站建設(shè)sem和seo有什么區(qū)別
  • 三門峽市湖濱區(qū)建設(shè)局網(wǎng)站巨量算數(shù)數(shù)據(jù)分析
  • 免費網(wǎng)站收錄入口百度云搜索引擎入口官網(wǎng)
  • 網(wǎng)站開發(fā)通常叫什么部門如何做市場推廣方案
  • 自己開加工廠怎么找訂單東莞seo優(yōu)化團隊
  • vr軟件開發(fā)需要學(xué)什么優(yōu)化推廣網(wǎng)站淄博
  • 南京溧水城市建設(shè)集團網(wǎng)站跨境電商網(wǎng)站開發(fā)
  • java答題對戰(zhàn)網(wǎng)站開發(fā)seo優(yōu)化服務(wù)商
  • vue做的小網(wǎng)站大興今日頭條新聞
  • 做web網(wǎng)站常用框架東莞網(wǎng)絡(luò)營銷推廣專業(yè)
  • 做網(wǎng)站后有人搶注品牌關(guān)鍵字開魯視頻
  • 阿里云上做網(wǎng)站靠譜嗎網(wǎng)絡(luò)優(yōu)化工程師證書
  • 建設(shè)銀行信用卡中心網(wǎng)站咸陽網(wǎng)站建設(shè)公司
  • 小程序登錄后臺seo聯(lián)盟
  • 網(wǎng)站網(wǎng)址有哪些臨沂seo整站優(yōu)化廠家
  • 網(wǎng)站制作公司源碼北京百度競價托管
  • 深圳做網(wǎng)站的給說網(wǎng)店推廣有哪些
  • 做網(wǎng)站最好最佳的資源搜索引擎
  • 環(huán)保網(wǎng)站查詢碾米是否做備案做個網(wǎng)站需要多少錢
  • jsp網(wǎng)站開發(fā)實例教程北京廈門網(wǎng)站優(yōu)化
  • 廈門網(wǎng)站流量優(yōu)化價格app推廣平臺放單平臺
  • 無錫做網(wǎng)站6seo技術(shù)助理