zoukankan      html  css  js  c++  java
  • NGUI图集字体

    UIFont里使用Symbols来指定字体时用Sprite前缀和名字自动分配的工具,前段时间工作需要时写的,具体用法有空时再写。

    using UnityEngine;
    using UnityEditor;
    using System.Collections.Generic;
    
    public class ParseFontAtlasWindow : EditorWindow
    {
        [MenuItem ("CustomTools/ParseFontAtlasWindow")]
        static void Init ()
        {
            ParseFontAtlasWindow window = (ParseFontAtlasWindow)EditorWindow.GetWindow (typeof (ParseFontAtlasWindow));
            window.Show();
        }
    
        string atlasPrefix = string.Empty;
    
        void OnGUI ()
        {
            atlasPrefix = EditorGUILayout.TextField(atlasPrefix);
            if (GUILayout.Button("ParseAtlas"))
            {
                UIFont tempFont = GetSelectedFont();
    
                UIAtlas tempAtlas = tempFont.atlas;
                foreach(UISpriteData tempSpriteData in tempAtlas.spriteList)
                {
                    if( tempSpriteData.name.StartsWith(atlasPrefix)) tempFont.AddSymbol(tempSpriteData.name.Remove(0,atlasPrefix.Length), tempSpriteData.name);
                }
                tempFont.MarkAsChanged();
            }
    
            if (GUILayout.Button("ClearSymbol"))
            {
                UIFont tempFont = GetSelectedFont();
                if(tempFont == null) return;
                tempFont.symbols.Clear();
                tempFont.MarkAsChanged();
            }
    
            if (GUILayout.Button("Active"))
            {
                UIFont tempFont = GetSelectedFont();
                if (tempFont == null) return;
                if (tempFont.bmFont.isValid) return;
                tempFont.bmFont.glyphs.Add(new BMGlyph());
                tempFont.MarkAsChanged();
            }
        }
    
        UIFont GetSelectedFont()
        {
            UIFont result = null;
            if(Selection.activeGameObject != null)
            {
                result = Selection.activeGameObject.GetComponent<UIFont> ();
            }
            return result;
        }
        
    }
    View Code
  • 相关阅读:
    图片文件重命名
    MySql基础学习-Sql约束
    MySql基础学习-库表操作
    java内存模型
    数据库常用函数整理
    linux用户管理
    Db2数据库在Linux下的安装和配置
    图像金字塔
    特征值与特征向量
    齐次线性方程组
  • 原文地址:https://www.cnblogs.com/sitt/p/4898367.html
Copyright © 2011-2022 走看看