showing Load 'name' (-1) couldn't be loaded because it has not been added to the built settings even after adding it

I have created 3 scenes (StartMenu, Game, Win) and added all of them to built setting with proper arrangement. StartMenu Scene has a button start which should take game to second Game Scene when onClick event is called on it.

The onClick event of start button is mapped to LevelManager Empty Object. That object has a script LevelManager whose code I have posted.

I have added all those scenes to built settings.alt text

but still I am getting this error:

Level 'name'(-1) couldn't be loaded because it has been added to the built settings.
To add a level to the built settings use menu File->Built settings.
UnityEngine.Application:LoadLevel(String)
LevelManager:LoadLevel(String) (at Assets/Scripts/LevelManager.cs:8) // 8 line is Application.LoadLevel line)
UnityEngine.EventSystems.EventSystem:Update()

Error Code:

LevelManager.cs

using UnityEngine;
using System.Collections;

public class LevelManager : MonoBehaviour {

    public void LoadLevel(string name){
	     	Application.LoadLevel(name);
    }

    public void QuitRequest(){
	        Debug.Log("Quit Requested"); 
    }

}

Dont call your function LoadLevel.

That already exists…

It’ll work but might get confusing.

Your code works fine but you are likely trying load a scene not added to the build settings.

This is what I got when my ‘Level2’ wasnt added, using your code:

Level ‘Level2’ (-1) couldn’t be loaded because it has not been added to the build settings.
To add a level to the build settings use the menu File->Build Settings…

As a note, it really doesnt help you here that you used the string “name” when calling your custom function.

LoadLevel("name"); //It just made things confusing to Debug

You are supposed to put a scene name in there. This functionality already works with Application.LoadLevel hence your custom function is a bit useless.

It would seem you’re trying to load a level called “name”, but you have no such level. In the On Click part of your button, there’s a parameter that currently says ‘name’. Just change ‘name’ to ‘Game’, and it should work.

Complete answer