Help with GUI, PlayerPrefs

How do you get PlayerPrefs.HasKey too work on your on textures, so when you see the main menu ( In game) you can only see play and when you starting playing and quit a the game and come back to it the “Continue” button shows.

I can get this to work using the following code, but the GUI look dose not suit my game.

Thannks is Advance.

  var btnWidth : int = 225;


{	


	if(GUI.Button(Rect(Screen.width / 2-(btnWidth/2),Screen.height/ 2-20,btnWidth,30),"New Game"))
	
	{
		PlayerPrefs.SetInt("PlayerLevel",1);
		Application.LoadLevel(1);
		print("Starting Game");
	}
	
	if(PlayerPrefs.HasKey("PlayerLevel"))
	
	
	{
	if(GUI.Button(Rect(Screen.width / 2-(btnWidth/2),Screen.height/ 2+20,btnWidth,30),"Continue Game"))
	{
		Application.LoadLevel(PlayerPrefs.GetInt("PlayerLevel"));
		print("Continuing Game");
	}
}
}

Use PlayerPrefs.Save() right after setting the PlayerLevel key, otherwise the PlayerPrefs will only be saved on Application.Quit - if your game crashes, PlayerPrefs isn’t saved.

if(GUI.Button(Rect(...),"New Game"))
{
   PlayerPrefs.SetInt("PlayerLevel",1);
   PlayerPrefs.Save();
   Application.LoadLevel(1);
   print("Starting Game");
}

EDITED: Ok, I’ve just realized that your problem is with the GUI appearance. Draw your button in Photoshop or other image editor, import it to Unity and use the texture version of GUI.Button:

var btnWidth = 255;
var buttonTex: Texture2D; // drag the button texture here

function OnGUI(){
   if(GUI.Button(Rect(...), buttonTex))
   {
   ...