【发布时间】:2018-07-18 08:37:36
【问题描述】:
我的问题很简单:我只想能够使用EditorGUILayout.PrefixLabel,但将文本颜色更改为白色。
但到目前为止我还没有运气。
我可以轻松地更改所有其他元素的颜色,但对于 PrefixLabel 没有任何效果。
我想坚持使用PrefixLabel,因为将所有标签和字段安排得井井有条的代码更少。
到目前为止我尝试过的一些事情:
使用EditorStyles.label.normal.textColor
var old = EditorStyles.label.normal.textColor;
EditorStyles.label.normal.textColor = Color.white;
EditorGUILayout.PrefixLabel("label Text");
EditorStyles.label.normal.textColor = old;
另外申请new GUIStyle(EditorStyles.label)
var old = EditorStyles.label.normal.textColor;
EditorStyles.label.normal.textColor = Color.white;
EditorGUILayout.PrefixLabel("label Text", new GUIStyle(EditorStyles.label));
EditorStyles.label.normal.textColor = old;
EditorGUILayout.PrefixLabel("label Text", new GUIStyle(EditorStyles.whiteLabel));
var old = GUI.contentColor;
EditorStyles.label.normal.textColor = Color.white;
EditorGUILayout.PrefixLabel("label Text");
GUI.contentColor = old;
使用GUI.skin.label.normal.textColor
var old = GUI.skin.label.normal.textColor;
GUI.skin.label.normal.textColor = Color.white;
EditorGUILayout.PrefixLabel("label Text");
GUI.skin.label.normal.textColor = old;
whiteTextStyle = new GUIStyle(EditorStyles.label)
{
normal = {
textColor = Color.white;
}
};
EditorGUILayout.PrefixLabel("label Text", whiteTextStyle);
任何提示我还能尝试什么?
【问题讨论】:
标签: unity3d customization unity3d-editor unity-editor