Question by
YoloJero · Jul 17, 2018 at 04:28 PM ·
colorcustom editorcolor changecustom inspectorlabels
How can I color a PrefixLabel?
My question is that simple: I just want to be able to use EditorGUILayout.PrefixLabel
but change the text color to white.
A fiew things I tried so far:
var old = EditorStyles.label.normal.textColor;
EditorStyles.label.normal.textColor = Color.white;
EditorGUILayout.PrefixLabel("label Text");
EditorStyles.label.normal.textColor = old;
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;
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 = TEXT_COLOR_SELECTED
}
};
EditorGUILayout.PrefixLabel("label Text", whiteTextStyle);
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.
Any hint what else I can try?
Comment
Your answer
Follow this Question
Related Questions
Changing particle colour (alpha) at runtime 1 Answer
Sprite not properly updating color 0 Answers
change color when have content 0 Answers
How to change texture color distance based (like in minecraft, but instead of biomes with distance)? 0 Answers
Custom inspector - How to serialize scene objects in ScriptableObject? 0 Answers