My question is that simple: I just want to be able to use EditorGUILayout.PrefixLabel
but change the text color to white.
But so far I have no luck.
I can easely change the color of all other elements but for the PrefixLabel
nothing is working.
I want to stick with PrefixLabel
since it simply is less code to have all labels and fields arranged well.
A fiew things I tried so far:
using 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;
additionally applying 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;
directly using EditorStyles.whiteLabel
EditorGUILayout.PrefixLabel("label Text", new GUIStyle(EditorStyles.whiteLabel));
using GUI.contentColor
var old = GUI.contentColor;
EditorStyles.label.normal.textColor = Color.white;
EditorGUILayout.PrefixLabel("label Text");
GUI.contentColor = old;
using 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;
using a new GUIStyle
whiteTextStyle = new GUIStyle(EditorStyles.label)
{
normal = {
textColor = Color.white;
}
};
EditorGUILayout.PrefixLabel("label Text", whiteTextStyle);
Any hint what else I can try?
EditorStyles.label.normal.textColor
would already have worked but I had to reset the color back after theEditorGUILayout.XYField
because the PrefixLabel was not drawed until the field call.