Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Writing an asset management GUI as part of our editor tools, I am in some places colouring LabelFields. Working mostly in the dark Pro skin, this seems to work just fine:

GUI.color = Color.green;         
EditorGUILayout.LabelField("Name", GUILayout.Width(75f));
GUI.color = Color.white;

When switching to the light default skin however, this colouring is no longer visible. The usual GUI.backgroundColor still functions fine there as it does in the dark skin.

Is this "foreground" colour something specific to the dark Pro skin? If so, is there perhaps another way to achieve a similar effect?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
+50

No, foregroundColor is not specific to Pro skin: it's just that font color in light skin is black.

The way GUI.foregroundColor (and all other colors in GUI) works is that it's multiplied by whatever color is drawn. But black multiplied by anything stays black, so the setting appears to have no effect.

Fortunately, there are pre-defined editor styles that use white font color in any skin. Use this line:

GUI.color = Color.green;         
EditorGUILayout.LabelField("Name", EditorStyles.whiteLabel, GUILayout.Width(75f));
GUI.color = Color.white;

By the way, in Light skin default GUI.color is not white, but some kind of gray, I don't know exact RGB values. So to restore default look, you should save this value and restore it later, not just set color to white.

share|improve this answer
    
Oh geez...and here I was thinking "hmm, my colors look muddy in the Pro skin. They must be multiplying them...". Tested and it works. Thank you ever so much. (p.s. you'll get the bounty once I can award it ;) ) –  Bart Mar 8 '13 at 11:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.