How can i use different skins in one GUI?

My idea is that I want to customize my GUI scene with different gui skins (just 2) because I have a selectiongrid and I want it to look different from the other controls like buttons, labels, etc.

I dont know if it’s possible or I have to use the same GUI skin for all the GUI interface? Please any comment I would be really appreciated! Thanks in advance!

Yes It is possible to use the different GUI skin for each control. you need to import different texture for each control. you can customize the each control ,there are different option for each control you can set texture of button or all other controls many more option. for use GUI Skin in your GUI you need to create an variable of type GUISkin in your program where you wants to use it. Please follow this :

var sfs:GUISkin;
function OnGUI()
{
	GUI.skin=sfs;

if(GUILayout.Button("APPLY LABEL"))
{
Debug.log("testing here");
}

}

Try this if face any problem then Ping please

More like this:

var skin1:GUISkin;
var skin2:GUISkin;

function OnGUI()
{
  GUI.skin = skin1;
  if (GUILayout.Button("Button with Skin1")) { Debug.log("First button clicked"); }

  GUI.skin = skin2;
  if (GUILayout.Button("Button with Skin2")) { Debug.log("Second button clicked"); }
}

Additionally, if you have sub-components that need to render with their own skins, you don’t want to mess with their rendering. There’s a pattern advocated by Unity, and that is to save the reference to current skin into a temporary variable and reapplying it later:

var skin1:GUISkin;
var skin2:GUISkin;
var temp:GUISkin;

function OnGUI()
{
  temp = GUI.skin;
  GUI.skin = skin1;
  if (GUILayout.Button("Button with Skin1")) { Debug.log("First button clicked"); }
  GUI.skin = temp;

  temp = GUI.skin;
  GUI.skin = skin2;
  if (GUILayout.Button("Button with Skin2")) { Debug.log("Second button clicked"); }
  GUI.skin = temp;
}
1 Like