我的问题很简单:我只想能够
EditorGUILayout.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;
直接使用
EditorStyles.whiteLabel
EditorGUILayout.PrefixLabel("label Text", new GUIStyle(EditorStyles.whiteLabel));
使用
GUI.contentColor
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;
使用
new GUIStyle
whiteTextStyle = new GUIStyle(EditorStyles.label)
{
normal = {
textColor = Color.white;
}
};
EditorGUILayout.PrefixLabel("label Text", whiteTextStyle);
有什么提示我还能试试吗?