How to add playerPrefs to this script?

Hi there

I know this is very newbie, but its really urgent that I get help with this please :slight_smile:

I have a menu Scene that has 9 Gui buttons with attached Textures to them and when clicked they take you to the relevant level.However they are all unlocked which makes the game pointless!

How would I go about adding PlayerPrefs to allow a level unlocking system. So from start of game only level one is not Greyed Out. After completing Lvl 1 then Lvl 2 is un-greyed and clickable and so on.

Thanks in advance , I am really battling with PlayerPrefs.

Here’s The JS script:

        public var button1 : Texture2D; 

        public var Button2 : Texture2D;

        public var Button3 : Texture2D;

        public var Button4 : Texture2D;
        public var Button5 : Texture2D; 

        public var Button6 : Texture2D;

        public var Button7 : Texture2D;

        public var Button8 : Texture2D;
        public var Button9 : Texture2D;
        public var Button10 : Texture2D;
        var btnTexture : Texture;

        // JavaScript
function OnGUI () {
	// Make a background box

	// Make the first button. If it is pressed, Application.Loadlevel (1)
	GUI.Box (Rect (1,200,1300,480),"Trial Version V1.0 Copyrite of GenY Tech Limited ©");
	       if (GUI.Button (Rect (10,230,200,200), button1)){
			if (GUI.Button (Rect (225,230,200,200), Button2)){
		Application.LoadLevel (4);
			if (GUI.Button (Rect (440,230,200,200), Button3)){
		Application.LoadLevel (5);
			if (GUI.Button (Rect (655,230,200,200), Button4)){
    	Application.LoadLevel (8);
			if (GUI.Button (Rect (870,230,200,200), Button5)){
    	Application.LoadLevel (9);
	    if (GUI.Button (Rect (1085,230,200,200), Button6)){
    	Application.LoadLevel (10);
		if (GUI.Button (Rect (250,10,900,100), btnTexture)){


	       if (GUI.Button (Rect (10,440,200,200), Button7)){
			if (GUI.Button (Rect (225,440,200,200), Button8)){
		Application.LoadLevel (12);
			if (GUI.Button (Rect (440,440,200,200), Button9)){
		Application.LoadLevel (13);
			if (GUI.Button (Rect (655,440,200,200), Button10)){
    	Application.LoadLevel (6);

you could set an int (lets call it Lvl_1) to 0 for false and 1 for true… then whenever you go to the menu have an if statement to check if PlayerPrefs.GetInt…etc if its 1 make it available… if not keep greyed

now to make it greyed out and not actually usable you can do something like this:

			GUI.Label (new Rect (10,230, 200, 200), "Level 1!", "Button");

it jsut makes it look like an unclickable button :slight_smile: