Application.LoadLevel working in the editor but not in the final build

Well, the title is effectively saying it all here. I have some code which is on my end-game score menu, which should load the main menu again when I click it. This works fine in the editor, but when I actually build it, it doesn’t work.

The code is simple enough. I’ve even used the exact code chunk to do the same thing: the main menu itself uses an identical block to load the game scene. Here’s the code: (SoundButton is a custom function to play a UI sound when the button is clicked).

function OnGUI() {
	if (SoundButton(Rect(20, menuHeight-40, 100, 25), GUIContent ("Main Menu","")))  {

Any ideas as to what might be wrong? The flow is Main Menu → Game Scene → Endgame Scene → Main Menu. I was previously able (again, using same code) to go from Game Scene to Main Menu with no problems.

I had the exact same issue. I have a game which loads level “menu” → “Select Player” → “Level X”… → “Menu” but when the player died and I had saved my values and wanted to LoadLevel(“menu”) it didn’t do anything in the WebPlayer, but the iOS build worked just fine.

I finally found a way to fix it. I think the the WebPlayer was being prevented from loading the level while it was saving to the PlayerPrefs… ?
My Quick-Fix is probably not the best solution to this problem, but at least it works.

//show the button to save the values, but remove it as soon as it has been triggered to prevent multiple triggers during the same click

if (GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 100, 200, 40), “”, button)){
isSubmittingScore = true;
//do whatever else needs to be done
PlayerPrefs.Save(); //force save changes made
Application.LoadLevel(“menu”); //doesn’t trigger in WebPlayer

} else

Application.LoadLevel(“menu”); //I know I’ve clicked to save the values and reload the menu, so just keep trying until it works… and this quick-fix works in the WebPlayer.

I’m having the exact same issue, with an equally simple process. I’ve tried every solution listed in the answers and nothing seems to work.

Everything works wonderfully in the dev build but crashes (sometimes ) on a LoadLevel.

Let me know if you ever found an answer.

Are you sure SoundButton does return the bool properly ? Try a print before the load to make sure it goes there. And what kind of build is that, standalone ? If it is webplayer and streamed, you might want to check if the level can be loaded, but it would be odd if it’s from end screen to main menu …

This may be obvious, but did you actually add the scenes to the build? File->Build Settings then click add current…