Multiple GUIstyles in one block wont work?

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?

I’m not quite sure what you expect from your code. You create 4 empty GUIStyles from scratch. So they don’t contain any background images or hover / active images. So those styles will all look more or less the same. For example your “myPanList” and your “myPanButtonlist” styles are exactly the same, so whatever you draw with them will look exactly the same.

You may want to have a look at my IMGUI crash course and read the section about the GUIStyle.

Specifically you didn’t setup any StyleStates. If you want to “clone” an existing style you can do:

GUIStyle myButtons = new GUIStyle("button");

This will grab the style named “button” from the curren GUI.skin and create a new instance of that style. That means myButtons will contain the same GUIStyleStates with the same background images as the button style.