GUISkin-how to show it?

Hi all

I’ve created a new gui skin by Assets>Create>GUISkin named mainMenuGUISkin,then I set all wanted variables for button(text color to light blue and several backgrounds which are a .png files imported) and in my script I have:

public class MenuCode : MonoBehaviour
{
    GUISkin geoscapeSkin;
    
    void OnGUI()
    {
        GUI.skin=geoscapeSkin;
        GUI.Button(new Rect(Screen.width/2,Screen.height/2,300,30),"Text1","button");
        GUI.Button(new Rect(Screen.width/2,Screen.height/2+35,300,30),"Text2","button"); 
    }
}

but there is no visible effect when I hit “play”.
I suspect that GUISkin geoscapeSkin defines a default skin,not mine-but how can I change that?TIt’s not described clear enough in the documentation of customizing GUI :confused:

public class MenuCode : MonoBehaviour
{
public GUISkin geoscapeSkin; // Drag your actual gui skin asset here

    void OnGUI()
    {
        GUI.skin=geoscapeSkin;
        // Since you are using a button, you don't need to add the GUIStyle "Button"
        // It is automatically used for buttons. If you wanted to use a GUIStyle from
        // the GUISkin, other then "Button", then you would added that after the text
        if ( GUI.Button(new Rect(Screen.width/2,Screen.height/2,300,30),"Text1"))
            ButtonText1Clicked();
        if ( GUI.Button(new Rect(Screen.width/2,Screen.height/2+35,300,30),"Text2"); 
            ButtonText2Clicked();
    }
    private void ButtonText1Clicked()
    {
        // Do what ever you wanted to do here
        Debug.Log("Button Text1 was clicked!");
    }
    private void ButtonText2Clicked()
    {
        // Do what ever you wanted to do here
        Debug.Log("Button Text2 was clicked!");
    }
}

My guess is, you’re not seeing any of the things you set in mainMenuGUISkin, because you haven’t drag’n’dropped the skin onto the geoscapeSkin variable. :slight_smile:

The problem is solved.
That drop shoud be made not on the ScriptFile->Default References component,but I had to select the object containing my script and there is a GUISkin reference the drop shoud be performed on.

var skin:GUISkin;

function OnGUI(){
	GUI.skin=skin;

//other stuff here

}