UnityEditor编辑器扩展开发如何快速修改字体颜色
Posted avi9111
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UnityEditor编辑器扩展开发如何快速修改字体颜色相关的知识,希望对你有一定的参考价值。
一般可以用gui.color,修改
但注意这全局修改,不改回来会有风险;
是整个Editor,官方的界面也被修改的那种风险
所以我们就想到了和不复制一份默认的,直接不改默认,只改扩展二次开发的部分代码即可
所以,有了以下代码:
public static GUIStyle CloneGUIStyle(GUIStyle source)
{
GUIStyle clone = new GUIStyle();
clone.normal = source.normal;
clone.hover = source.hover;
clone.active = source.active;
clone.onNormal = source.onNormal;
clone.onHover = source.onHover;
clone.onActive = source.onActive;
clone.focused = source.focused;
clone.onFocused = source.onFocused;
clone.border = source.border;
clone.margin = source.margin;
clone.padding = source.padding;
clone.overflow = source.overflow;
clone.font = source.font;
clone.imagePosition = source.imagePosition;
clone.alignment = source.alignment;
clone.wordWrap = source.wordWrap;
clone.clipping = source.clipping;
clone.contentOffset = source.contentOffset;
clone.fixedWidth = source.fixedWidth;
//clone.fontSize = source.fontSize;
//clone.fontStyle = source.fontStyle;
clone.fixedHeight = source.fixedHeight;
clone.stretchWidth = source.stretchWidth;
clone.stretchHeight = source.stretchHeight;
//clone.lineHeight = source.lineHeight;
return clone;
}
调用方法就不贴了
需要有一定Unity Editor编程基础,要不要自己琢磨下要怎么调用
fontDistStyle = CloneGUIStyle(GUI.skin.label);
fontDistStyle.normal.textColor = Color.gray;
以上是关于UnityEditor编辑器扩展开发如何快速修改字体颜色的主要内容,如果未能解决你的问题,请参考以下文章
UnityEditor编辑器扩展开发-自定义Shader入门
UnityEditor编辑器扩展开发-自定义Shader入门
UnityEditor编辑器扩展开发之一些有用的Gizmos扩展方法
记一次UnityEditor编辑器扩展开发参考BuildReportTools插件自定义高效列表