Unity3D 【编辑器扩展】一键批量修改预设UGUI Text字体
2017-08-01 10:56
696 查看
我们做项目的时候经常会遇到要换个字体的工作情况,比如美工同学觉着字体不好看或者要做其它语言版本什么的。遇到这种情况我们总不能一个标签一个标签的去找到它们把字体换了,累不累就不说了,万一漏了也是麻烦事。
转载请保留原文链接:http://blog.csdn.net/andyhebear/article/details/51393259
[csharp] view
plain copy
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() {
}
}
转载请保留原文链接:http://blog.csdn.net/andyhebear/article/details/51393259
[csharp] view
plain copy
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() {
}
}
相关文章推荐
- Unity3D 【编辑器扩展】一键批量修改预设UGUI Text字体
- Unity-【编辑器扩展】一键批量修改预设UGUI Text字体
- Unity3D开发之编辑器统一修改Text字体
- UGUI在同一个Text里修改字体不同的颜色、大小等设置
- word字体大小与公式编辑器字体对照表 如何批量修改word里的公式
- word字体大小与公式编辑器字体对照表 如何批量修改word里的公式
- 【UGUI/NGUI】一键换Text/Label字体
- Unity一键修改NGUI字体的编辑器脚本
- 修改TextField的Placeholder属性的字体大小,颜色
- Unity3D 实例化UGUI自适应的预设
- 修改textField的placeholder的字体颜色、大小
- Linux gvim 编辑器修改配色方案、字体、字号
- 批量修改|导入Unity3d资源属性,帮助那些遗忘勾、选项的美术同学们 (其实我做美术的时候也一样有健忘症)
- Unity3d 批量修改贴图导入设置工具脚本
- Notepad++关联文件扩展名,修改字体大小
- 使用selector修改TextView中字体的颜色
- [Unity3D]编辑器扩展之数组或List显示
- VC6集成环境编辑器字体的修改
- Unity3D使用经验总结 编辑器扩展篇
- ios设置字体-黑体,加粗等 修改textField的placeholder的字体颜色、大小