| using UnityEngine; | 
| using System.Collections; | 
| using UnityEditor; | 
| using System.Text; | 
|   | 
| public class FontMaker | 
| { | 
|     static public Font m_myFont; | 
|     static public TextAsset m_data; | 
|     static private BMFont mbFont = new BMFont(); | 
|   | 
|     static public void GenerateCharacterInfo() | 
|     { | 
|   | 
|         CustomFontReader.Load(mbFont, m_data.name, m_data.bytes); | 
|         CharacterInfo[] characterInfo = new CharacterInfo[mbFont.glyphs.Count]; | 
|         for (int i = 0; i < mbFont.glyphs.Count; i++) | 
|         { | 
|             BMGlyph bmInfo = mbFont.glyphs[i]; | 
|             CharacterInfo info = new CharacterInfo(); | 
|             info.index = bmInfo.index; | 
|             info.uv.x = (float)bmInfo.x / (float)mbFont.texWidth; | 
|             info.uv.y = 1 - (float)bmInfo.y / (float)mbFont.texHeight; | 
|             info.uv.width = (float)bmInfo.width / (float)mbFont.texWidth; | 
|             info.uv.height = -1f * (float)bmInfo.height / (float)mbFont.texHeight; | 
|             info.vert.x = (float)bmInfo.offsetX; | 
|             info.vert.y = (float)bmInfo.offsetY; | 
|             info.vert.width = (float)bmInfo.width; | 
|             info.vert.height = (float)bmInfo.height; | 
|             info.width = (float)bmInfo.advance; | 
|             characterInfo[i] = info; | 
|         } | 
|         m_myFont.characterInfo = characterInfo; | 
|   | 
|         EditorUtility.SetDirty(m_myFont); | 
|         AssetDatabase.SaveAssets(); | 
|         AssetDatabase.Refresh(); | 
|     } | 
|   | 
|     [MenuItem("策划工具/美术字制作")] | 
|     static public void OpenFontMakerWindow() | 
|     { | 
|         Rect windowRect = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 100, 400, 200); | 
|         FontMakerWindow modalTipswindow = EditorWindow.GetWindowWithRect<FontMakerWindow>(windowRect, true, "自定义字体编辑器", false); | 
|     } | 
|   | 
| } |