Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Nemo101 · Aug 04, 2012 at 07:57 PM · guicontrollermenu

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 :) }

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]);

} }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Aug 05, 2012 at 12:22 PM

http://answers.unity3d.com/questions/8019/how-do-i-use-an-xbox-360-controller-in-unity.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Controller Controlled Menu? 2 Answers

Controller input sluggish on menus. 2 Answers

Touchscreen for unity 2 Answers

Game Menus WIth Keyboard Input Control 1 Answer

Accessing the Asset's setting from code using Wizards/Editor classes? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges