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
  • 相关阅读:
    java接口工厂模式理解
    ViewDragHelper的点击事件处理
    ViewDragHelper的使用
    路径跟踪 PathMeasure的简单使用
    view事件分发源码理解
    layoutInflater参数解析与源码分析
    安卓menu的介绍与使用
    安卓广播api介绍,给自己理清楚概念
    动态删除集合遇到的一些问题理解
    【翻译】借助 NeoCPU 在 CPU 上进行 CNN 模型推理优化
  • 原文地址:https://www.cnblogs.com/sitt/p/4898367.html
Copyright © 2011-2022 走看看