In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to use BMFont to make art fonts, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problems. Through this article, I hope you can solve this problem.
Generate Number.fnt and Number_0.png files, drag them to the corresponding location of Unity, and continue to the next step
What the arrow points to is the ultimate goal we want to get, and just use it in the font at the text.
The following steps must be completed before using Tools-> BMFont Maker:
Using UnityEngine; using UnityEditor; public class BMFontEditor: EditorWindow {[MenuItem ("Tools/BMFont Maker")] static public void OpenBMFontMaker () {EditorWindow.GetWindow (false, "BMFontMaker", 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); / / borrow NGUI encapsulated read class 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 Success"); Close(); } } } 将这个类放入工程中,这样在 Tools 中才可以找到 BMFont Maker,它的作用是赋予字体的详细信息,由于它是借助 NGUI 来实现的工具,所以得加上 NGUI 中的以下类:After reading the above, have you mastered how to use BMFont to make art fonts? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
The left and right direction of the mouse is reversed.
© 2024 shulou.com SLNews company. All rights reserved.