Unity-【编辑器扩展】一键批量修改预设UGUI Text字体
来源:互联网 发布:淘宝信用卡付款手续费 编辑:程序博客网 时间:2024/06/06 18:36
我们做项目的时候经常会遇到要换个字体的工作情况,比如美工同学觉着字体不好看或者要做其它语言版本什么的。遇到这种情况我们总不能一个标签一个标签的去找到它们把字体换了,累不累就不说了,万一漏了也是麻烦事。
转载请保留原文链接:http://blog.csdn.net/andyhebear/article/details/51393259
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEditor;
- using System.Collections;
- using System.Collections.Generic;
- //[InitializeOnLoad]
- public class ChangeFontWindow : EditorWindow {
- static ChangeFontWindow() {
- //toChangeFont = new Font("Arial");
- //toChangeFontStyle = FontStyle.Normal;
- }
- [MenuItem("Window/Change Font")]
- private static void ShowWindow() {
- ChangeFontWindow cw= EditorWindow.GetWindow<ChangeFontWindow>(true, "Window/Change Font");
- }
- Font toFont = new Font("Arial");
- static Font toChangeFont;
- FontStyle toFontStyle;
- static FontStyle toChangeFontStyle;
- private void OnGUI() {
- GUILayout.Space(10);
- GUILayout.Label("目标字体:");
- toFont = (Font)EditorGUILayout.ObjectField(toFont, typeof(Font), true, GUILayout.MinWidth(100f));
- toChangeFont = toFont;
- GUILayout.Space(10);
- GUILayout.Label("类型:");
- toFontStyle = (FontStyle)EditorGUILayout.EnumPopup(toFontStyle, GUILayout.MinWidth(100f));
- toChangeFontStyle = toFontStyle;
- if (GUILayout.Button("修改字体!")) {
- Change();
- }
- }
- public static void Change() {
- //获取所有UILabel组件
- if (Selection.objects == null || Selection.objects.Length==0) return;
- //如果是UGUI讲UILabel换成Text就可以
- Object[] labels = Selection.GetFiltered(typeof(Text), SelectionMode.Deep);
- foreach (Object item in labels) {
- //如果是UGUI讲UILabel换成Text就可以
- Text label = (Text)item;
- label.font = toChangeFont;
- label.fontStyle = toChangeFontStyle;
- //label.font = toChangeFont;(UGUI)
- Debug.Log(item.name + ":" + label.text);
- //
- EditorUtility.SetDirty(item);//重要
- }
- }
- private void OnEnable() {
- }
- private void OnDisable() {
- }
- private void Update() {
- }
- private void OnDestroy() {
- }
- }
1 0
- Unity-【编辑器扩展】一键批量修改预设UGUI Text字体
- Unity3D 【编辑器扩展】一键批量修改预设UGUI Text字体
- Unity3D 【编辑器扩展】一键批量修改预设UGUI Text字体
- Unity一键修改NGUI字体的编辑器脚本
- unity-ugui的text字体模糊解决办法
- 扩展Unity3d编辑器,批量修改Label字体颜色
- Unity UGUI--Text组件
- Unity UGUI基础之Text
- UNITY UGUI Rich Text 控件
- 【unity 笔记】ugui艺术字体
- 一键生成UGUI艺术字体
- 关于Unity里面UGUI的Text字体无法显示以及尺寸无法改变的问题
- Unity编辑器扩展之修改扩展脚本的成员变量
- Unity UGUI学习(一)
- Unity-UGUI框架<一>
- Unity3D开发之编辑器统一修改Text字体
- 【Unity】UGUI Image组件检视面板编辑器扩展(ImageEditor类)
- 【Unity】UGUI无法修改字体大小
- TheDAO被攻击事件考察报告
- 为什么用copy for NSString属性?
- Java NIO 学习(一)--简介
- java组合模式(Composite)-结构性
- div反弹
- Unity-【编辑器扩展】一键批量修改预设UGUI Text字体
- java判断字符串是否为空的方法总结
- git 本地存在的工程上传到指定仓库
- how to register a cell for UITableViewCell
- 为Centos6.5配置KVM环境
- BZOJ2006——[NOI2010]超级钢琴
- 分析一款病毒程序
- java中string.trim()函数的使用
- Android ThumbnailUtils 视频缩略图