Controllable GUI

Hi out there,##

##I’ve got a problem …
##I want a GUI menu controllable with Xbox 360 Controller …
##My problem is with keyboard all works fine, but how can I translate this to the XB controller ?
##On my way it does not work like it should do …
##See here:

var p2 : GUIText;

var p2p = 0;

var menuOptions = new String[9];
menuOptions[0] = “SinglePlayer”;
menuOptions[1] = “Multiplayer”;
menuOptions[2] = “Credits”;

menuOptions[3] = “Classic”;
menuOptions[4] = “Arcade”;
menuOptions[5] = “Back”;

menuOptions[6] = “Classic_P2”;
menuOptions[7] = “Arcade_P2”;
menuOptions[8] = “Back_P2”;

function Update()
{
Ball_Java.PlayerScore = 0; print(“player++ reset”);
Ball_Java.EnemyScore = 0; print(“enemy++ reset”);
print(axisInput);

// MenuButtons
if (Input.GetAxisRaw(“Y axis”)== -axis)
{
axisInput = 1;
}

if (Input.GetAxisRaw(“Y axis”) == axis)
{
axisInput = -1;

}

if (Input.GetKeyDown(“down”))
{
//MenuButton++ ;
axisInput = 1;
print(“-”);
}

if (Input.GetKeyDown(“up”))
{
//MenuButton–;
axisInput = -1;
print(“+”);
}
///

if(axisInput == 1)
{
MenuButton += 1;
axisInput = 0;
}

if (axisInput == -1)
{
MenuButton -= 1;
axisInput = 0;
}

if(MenuButton < 0){MenuButton = 0;}
if(MenuButton > 2){MenuButton = 2;}
//
if(MenuLevel == 0){
if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 0)
{MenuLevel = 1; MenuButton = -1;}

if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 1)
{MenuLevel = 2; MenuButton = -1;}

if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 2)
{Application.LoadLevel(“Credits”); print(“2”);}

}

if(MenuLevel == 1){ //SinglePlayer
if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 0)
{Application.LoadLevel(“loading”);}

if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 1)
{Application.LoadLevel(“loading_power”); print(“1”);}

if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 2)
{MenuLevel = 0; MenuButton = -1;}
}

if(MenuLevel == 2){ //Multiplayer
p2p = 1;

if(Input.GetKeyDown(KeyCode.Joystick2Button7))
{MenuLevel = 3; p2p = 0;}

  if(Input.GetKeyDown(KeyCode.Joystick1Button1))
  {MenuLevel = 0; p2p = 0;}

}

if(MenuLevel == 3){ //MultiPlayer
if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 0)
{Application.LoadLevel(“loadingp2”);}

if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 1)
{Application.LoadLevel(“loadingp2_power”); print(“1”);}

if(Input.GetKeyDown(KeyCode.Joystick1Button0) && MenuButton == 2)
{MenuLevel = 0; MenuButton = -1;}
}

}

function OnGUI()
{

if(p2p == 1)
{
p2.text = “Player 2 press start to continue | Press B to go back”;
}
if(p2p == 0)
{
p2.text = “”; //empty :slight_smile:
}

GUI.skin = s1;
if(MenuLevel == 0){
GUI.SetNextControlName (“SinglePlayer”);

if (GUI.Button(Rect(570,600,300,30), "SinglePlayer")) {

    Application.LoadLevel(1);
    print("1");
}


GUI.SetNextControlName ("Multiplayer");

if (GUI.Button(Rect(570,660,300,30), "2 Players")) {

     Application.LoadLevel(2);
     print("2");

}


GUI.SetNextControlName ("Credits");

if (GUI.Button(Rect(570,720,300,30), "Credits")) {

     Application.LoadLevel(3);
     print("3");

}



GUI.FocusControl (menuOptions[MenuButton]);

}
///////
if(MenuLevel == 1){
GUI.SetNextControlName (“Classic”);

if (GUI.Button(Rect(570,600,300,30), "Classic")) {

    Application.LoadLevel(1);
    print("1");
}


GUI.SetNextControlName ("Arcade");

if (GUI.Button(Rect(570,660,300,30), "Arcade")) {

     Application.LoadLevel(2);
     print("2");

}



GUI.SetNextControlName ("Back");

if (GUI.Button(Rect(570,720,300,30), "Back")) {

    Application.Quit();
    print("Quitted");

}




GUI.FocusControl (menuOptions[MenuButton]);

}

  ///////
   if(MenuLevel == 3){
    GUI.SetNextControlName ("Classic_P2");

if (GUI.Button(Rect(570,600,300,30), "Classic")) {

    Application.LoadLevel(1);
    print("1");
}


GUI.SetNextControlName ("Arcade_P2");

if (GUI.Button(Rect(570,660,300,30), "Arcade")) {

     Application.LoadLevel(2);
     print("2");

}



GUI.SetNextControlName ("Back_P2");

if (GUI.Button(Rect(570,720,300,30), "Back")) {

    Application.Quit();
    print("Quitted");

}




GUI.FocusControl (menuOptions[MenuButton]);

}
}