Start menu gui wont load scene

Hi Guys,

I am really new to Unity3D Free. I have used a load GUI script from Unity’s free ‘Lerpz Escapes’ tutorial and adapted it slightly for my scene. The loading scene comes up nicely with an image i made and the buttons.

When i press ‘Start’, ‘Loading…’ pops up, however it doesn’t load the scene. I am sure it is some tiny thing i have done incorrectly, but does someone please have an answer for this?

‘L4NLevel1’ is my scene i want to load, i tryed putting it in the same folder as the ‘StartMenuGUI’ scene but that doesnt work either.

Code:

#pragma strict
// Make the script also execute in edit mode
@script ExecuteInEditMode()
var gSkin : GUISkin;
var backdrop : Texture2D; // our backdrop image goes in here.
private var isLoading = false; // if true, we'll display the "Loading..." message.

function OnGUI()
{
	if (gSkin)
		GUI.skin = gSkin;
	else
		Debug.Log("StartMenuGUI: GUI Skin object missing!");
		
	var backgroundStyle : GUIStyle = new GUIStyle();
	backgroundStyle.normal.background = backdrop;
	GUI.Label ( Rect( (Screen.width - (Screen.height * 2)) * 0.75, 0, Screen.height * 2,Screen.height), "", backgroundStyle);
	//GUI.Label ( Rect( (Screen.width/2)-197, 50, 400, 100), "LEFT4NED","mainMenuTitle");
	
	if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 160, 140, 70), "Play"))
	{
		isLoading = true;
		Application.LoadLevel("L4NLevel1"); // load the game level.
	}
	
	
	var isWebPlayer = (Application.platform == RuntimePlatform.OSXWebPlayer ||
	Application.platform == RuntimePlatform.WindowsWebPlayer);
	
	if (!isWebPlayer)
	{
		if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 80, 140, 70), "Quit"))
		Application.Quit();
	}

	if (isLoading)
		GUI.Label ( Rect( (Screen.width/2)-110, (Screen.height / 2) - 60, 400, 70),"Loading...", "Loading...");
}

Add your scene to File->Build Settings… Scenes In Build.

Are you sure “L4NLevel1” is correct and capilised exactly in that way?

Best thing to do if you are just starting out and trying to debug a piece of code is to use the Debug.Log() method to print stuff to the console.

Try

if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 160, 140, 70), "Play"))
{
   Debug.Log("I've pressed the button");
   isLoading = true;
   Application.LoadLevel("L4NLevel1"); // load the game level.
}

That way you’ll know you are definitely accessing the block of code which loads the level.

Apart from that it is difficult to suggest answers without more detail.