GUI Customizing Multiple Elements

Hello everyone.
I ve being searching everywhere for a tutorial without success. so i guess here is where the answer is lying

I have 3 buttons, and i want to add a single GUIStyle and use the “Custom Style” option in GuiSkin so i can create all
3 together and be able to have different icon for normal/hoovered/active buttons.

How do i call those custom styles within a script?

using UnityEngine;
using System.Collections;
using System.IO;

	public GUISkin gSkin;



	void OnGUI() {
		
		GUI.skin = gSkin;
		
		if(ShowMenu)
		{
		GUI.Box(new Rect(Screen.width - 740,Screen.height - 580 , 400 , 250),"Main Menu");
		if(GUI.Button(new Rect(Screen.width - 600 , Screen.height - 530 , 120 , 30) ,"Start"))
		{
				ShowMenu = false;
				ShowStart = true;


				
		}
		if(GUI.Button(new Rect(Screen.width - 600 , Screen.height - 480 , 120 , 30) ,"Highscores"))
		{
				ShowScores = true;
				ShowMenu = false;
				HighscoreList.LoadList();
				
		
				
				
		}
		if(GUI.Button(new Rect(Screen.width - 600 , Screen.height - 430 , 120 , 30) ,"Exit"))
		{
			Application.Quit();
		}
		}

where it says “start” i would like to call custom style button with the name Strart_Button in Quit Quit_Button etc etc.

Everywhere it says to make seperate GuiSkins, but im sure i can call every guiStyle i need from 1 GuiSkin… or else it wouldnt make sense having the option for Custom Elements…

Can anyone help me?

GUISkin.GetStyle(“Name”) and put that in the respective function, i.e. GUI.button(rect, content, style)

i ve tried it

 				if(GUI.Button(new Rect(Screen.width - 600 , Screen.height - 530 , 120 , 30) ,GUISkin.GetStyle("Start_Button")))

but i get those errors
a) error CS0120: An object reference is required to access non-static member UnityEngine.GUISkin.GetStyle(string) b)error CS1502: The best overloaded method match for UnityEngine.GUI.Button(UnityEngine.Rect, string)’ has some invalid arguments
c)error CS1503: Argument #2' cannot convert object’ expression to type `string’

i ve tried for content to leave it empty and write “” but still it didnt work :confused:

yes, you have to use your skin “gSkin” gSkin.GetStyle(“Start_Button”)

oh ofcoarse… sorry about that. But it still seems that it cant read the Strings im writing in (“Start_Button”). Its not misspelled.
i still get the error b and c, which i guess its somewhere else the mistake…
GUISkin its on the script. It is names GUI.skin = gSkin… aaaaaargh

take a look at the function prototype in the scripting manual
GUI.Button(Rect, Content, Style) if i remember correctly. You can use “” if you dont want any content.

it works :slight_smile: thanks. yea i tweaked everything you said and i forgot to add the “” back. now that you reminded me everything works like clock :slight_smile: