Does anyone know how to do this? I'm in need of this. With this the game will have taken a huge step forward so I can start linking the scenes to the main grid and back.
Right now, my script to load the main grid looks like this:
Code: Select all
function OnTriggerEnter(){
Application.LoadLevel("Sector 1");
}
Code: Select all
var availableLevels : String[];
var windowWidth : int = 200;
var windowHeight : int = 100;
var target : ShipControlScript;
private var showMenu : boolean = false;
function OnTriggerEnter () { //Replace TriggerAction with your desired means of triggering the menu.
target.flyingSpeed = 0; //stops ship in tracks and loads menu
showMenu = true;
}
function OnGUI () {
if (showMenu) {
GUI.Window(0,
Rect((Screen.width / 2) - (windowWidth / 2),
(Screen.height / 2) - (windowHeight / 2),
windowWidth,
windowHeight),
LevelSelect,
"Enter Star System?"); //Creates a window with ID 0 in the center of the screen using the function LevelSelect with the title, "Select a level!"
}
}
function LevelSelect (id : int) {
for (var levelName : String in availableLevels) {
if (GUILayout.Button(levelName)) {
Application.LoadLevel(levelName);
}
}
if (GUILayout.Button("Cancel")) { //Gives the player the opportunity to back out of the menu.
showMenu = false;
}
}