Unity – User input – Load Scene – GetButton – JS

Level1.unity

1. MAIN TOP MENU> GameObject> Create Other> Cube
2. Hierarchy> Cude> Inspector> Add Component> New Script> JavaScript> LoadLevel2.js

LoadLevel2.js

#pragma strict

function Update() {
// press spacebar to load Level2
if(Input.GetButton("Jump")){
 Application.LoadLevel ("Level2"); 
}
}

3. Files> Save Scene as… Level1.unity

Level2.unity

1. MAIN TOP MENU> GameObject> Create Other> Sphere
2. Files> Save Scene as… Level2.unity

Building Settings

1. File> Building Settings…
2. Project> DRAG AND DROP Level1 over Building Settings> Scenes in Build
3. Project> DRAG AND DROP Level2 over Building Settings> Scenes in Build

Play

TOP Play button, Level1.unity starts -> press keyboard spacebar -> Level2.unity starts