So, I got tired of:
//saving current style
TextAnchor alignment4 = GUI.skin.button.alignment;
int fontSize4 = GUI.skin.button.fontSize;
Color contentColor4 = GUI.contentColor;
Color backgroundColor4 = GUI.backgroundColor;
//drawings labels and buttons
//...
//restoring GUIstyle
GUI.skin.button.alignment = alignment4;
GUI.contentColor = contentColor4;
GUI.backgroundColor = backgroundColor4;
GUI.skin.button.fontSize = fontSize4;
every time I need a custom style for a Label and Button and I tried this:
GUIStyle myPanList = new GUIStyle();
myPanList.alignment = TextAnchor.MiddleRight;
myPanList.fontStyle = FontStyle.Bold;
myPanList.fontSize = 18;
myPanList.normal.textColor = Color.white;
GUIStyle myPanButtonlist = new GUIStyle();
myPanButtonlist.alignment = TextAnchor.MiddleRight;
myPanButtonlist.fontStyle = FontStyle.Bold;
myPanButtonlist.fontSize = 18;
myPanButtonlist.normal.textColor = Color.white;
GUIStyle myEmpty = new GUIStyle();
myEmpty.alignment = TextAnchor.MiddleRight;
myEmpty.fontStyle = FontStyle.Italic;
myEmpty.fontSize = 18;
GUIStyle myButtons = new GUIStyle();
myButtons.alignment = TextAnchor.MiddleCenter;
myButtons.fontStyle = FontStyle.Bold;
myButtons.fontSize = 18;
GUI.Label(new Rect(1560f, 150f, 340f, 30f), "[my LIST]", myPanList);
if (condition)
{
GUI.Label(new Rect(1560f, 180f, 340f, 30f), "<text bla bla>", myEmpty);
}
else
{
GUI.Button(new Rect(90f, (float)(buttonCount * 30), 390f, 30f), "asdbasdasdasd", myPanButtonlist)
}
//etc
but the problem is that even explicitly stated GUI.Button
is being displayed as Label
. And i can’t figure out why would that be, I never specified any custom temporal local GuiStyle to be button or label, only to have specific text aligment, style and size. What gives?