I have followed a tutorial for creating a character selection screen, so far everything works for that but i decided to create a Main menu to select game modes and exit the game.
the script i have all together for it is as follows, but i will post the area where i am having trouble
Edit: last comment i made says it, but ill put it up here as well, resolved the issue for one selection, but now it is saying i have an EOF of “Else” which does not make to much sense, trying to figure it out, commenting them out (the last 3 selections) works fine, so i think i have an extra {} somewhere in my code.
var guiskin : GUISkin;
enum CurrentFocus2 {button1=1, button2=2, button3=3, button4=4}
private var currentFocus2 : CurrentFocus = CurrentFocus.button1;
private var selectSeq : boolean;
var guiStyles : String[];
function Awake(){
Screen.lockCursor = true; //Locks out mouse (use Escape to bring back tempory)
}
function Update ()
{
if (Input.GetKeyDown("space")){
SelectCharacter();
}
if (Input.GetKeyDown (KeyCode.Escape)){
Application.Quit();}
switch (currentFocus2){
case 1:
if(Input.GetKeyDown(KeyCode.UpArrow)){
currentFocus2 = 4;}
else if (Input.GetKeyDown(KeyCode.DownArrow)){
currentFocus2 = 2;}
break;
case 2:
if(Input.GetKeyDown(KeyCode.UpArrow)){
currentFocus2 = 1;}
else if (Input.GetKeyDown(KeyCode.DownArrow)){
currentFocus2 = 3;}
break;
case 3:
if(Input.GetKeyDown(KeyCode.UpArrow)){
currentFocus2 = 2;}
else if (Input.GetKeyDown(KeyCode.DownArrow)){
currentFocus2 = 4;}
break;
case 4:
if(Input.GetKeyDown(KeyCode.UpArrow)){
currentFocus2 = 3;}
else if (Input.GetKeyDown(KeyCode.DownArrow)){
currentFocus2 = 1;}
break;
}
}
function OnGUI () {
GUI.skin = guiskin; //Will organize script later
GUI.SetNextControlName("button1");
GUI.Button(Rect(500,200,150,75), "", guiStyles[1]); //Character 1
GUI.SetNextControlName("button2");
GUI.Button(Rect(500,300,150,75), "", guiStyles[2]); //Character 2
GUI.SetNextControlName("button3");
GUI.Button(Rect(500,400,150,75), "", guiStyles[3]); //Character 3
GUI.SetNextControlName("button4");
GUI.Button(Rect(500,500,150,75), "", guiStyles[4]); //Character 4
switch (currentFocus2) {
case 1:
GUI.FocusControl("button1");
break;
case 2:
GUI.FocusControl("button2");
break;
case 3:
GUI.FocusControl("button3");
break;
case 4:
GUI.FocusControl("button4");
break;
}
}
function SelectCharacter() {
selectSeq = true;
guiStyles[currentFocus2] = guiStyles[currentFocus2].ToString() + "_2";
yield WaitForSeconds(0.1);
guiStyles[currentFocus2] = currentFocus2.ToString();
yield WaitForSeconds(1.0);
if (guiStyles[currentFocus2] == guiStyles[1]);
{Application.LoadLevel("Character_Select");}
else if (guiStyles[currentFocus2] == guiStyles[2]);
{Application.LoadLevel("Character_Select");}
else if (guiStyles[currentFocus2] == guiStyles[3]);
{Application.LoadLevel("Options_Menu");}
else if (guiStyles[currentFocus] == guiStyles[4]);
{Application.Quit();}
}