GUI, making main page lead into an instructions page

I am following will goldstones Unity 3.x book and my script doesn’t seem to work, but I get no errors.

Here’s the code

else if (menuPage == "instructions")
			{
				Debug.Log ("does it work?");
				GUI.Label(new Rect(instructions),
					"You awake on a mysterious island... Find a way to signal for help or face certain doom!");
				Debug.Log("doesitwork2?");
				if(GUI.Button(new Rect(quitButton), "Back"))
				{
					Debug.Log ("doesitwork3");
					audio.PlayOneShot(beep);
					menuPage="main";
				}
			}

The first two debug.logs work perfectly, but the third doesn’t run at all. Also, all of the text in the label doesn’t seem to show up at all, but no errors. I don’t think that
“if(GUI.Button(new Rect(quitButton), “Back”))” runs at all. I keep looking over the book but I don’t see any differences between what I have and what the book has.

Anyone have an Idea?

else if (menuPage == “instructions”)

I can see from your code its linking to :

if(GUI.Button (new Rect(quitButton), "Quit"))

whereas it needs to link to :

if(menuPage == "main")

Hi!
I had the same problem as you, exactly the same code. Our problem is that our “else if” is inside the initial if. It has to be outside the curly braces from our first if.
Hope this helps!

:slight_smile: