Making a loadlevel script that saves a lot of space

Hey guys I am getting into unity.

I made a loadlevel script that will save me a lot of time.I made this so that I do not have to make a script everytime I make a new scene.

but I have problems,here is my script:

#pragma strict

var levelname : string;

function Start () {

}

function OnTriggerEnter () {

	Application.LoadLevel("levelname");

}

Hopefully you can help me.

The problem is the quotes around the levelname parameter that you pass to Application.LoadLevel(). The quotes mean you are passing in the literal string “levelname” every time, such that Unity will always try and load Assets/levelname.scene.

If you get rid of the quotes, you will then be passing the variable levelname:

#pragma strict
 
var levelname : String;

function OnTriggerEnter () {
    Application.LoadLevel(levelname);
}