Reputation: 11319
void DrawItemBackgroundColor(Rect bgRect)
{
if (Event.current.type == EventType.Repaint)
{
Color oldColor = GUI.color;
GUI.color = new Color(255, 182, 193);
var rect = bgRect;
rect.height = Styles.headerBackground.fixedHeight;
Styles.headerBackground.Draw(rect, false, false, false, false);
rect.y += rect.height;
rect.height = bgRect.height - rect.height;
Styles.background.Draw(rect, false, false, false, false);
GUI.color = oldColor;
}
}
This should change the color to pink :
GUI.color = new Color(255, 182, 193);
But it does nothing.
But if I'm doing :
GUI.color = Color.red;
It will change it to red the problem is that Color don't have all the colors only some.
Upvotes: 1
Views: 411
Reputation: 11319
Solution is to use Color32 :
void DrawItemBackgroundColor(Rect bgRect)
{
if (Event.current.type == EventType.Repaint)
{
Color oldColor = GUI.color;
GUI.color = new Color32(255, 182, 193,100);
var rect = bgRect;
rect.height = Styles.headerBackground.fixedHeight;
Styles.headerBackground.Draw(rect, false, false, false, false);
rect.y += rect.height;
rect.height = bgRect.height - rect.height;
Styles.background.Draw(rect, false, false, false, false);
GUI.color = oldColor;
}
}
This line make it color in nice light pink color :
GUI.color = new Color32(255, 182, 193,100);
Upvotes: 0
Reputation: 2417
For your case :
GUI.color = new Color(255f/255f, 182f/255f, 193f/255f);
So you can use Color32 by 0~255 or Use Color by 0~1;
Upvotes: 1