- Home /
Gamepad input enum eType not working
I am making a SIMON game on PS Vita. I want to have touch but also button controls. I have the touch controls working as they should but the gamepad buttons don't work at all. I tried several things with 'GetKey' and 'GetButton' but it just isn't working. The part of "void Update" works. The last three parts are the working touch parts, the rest is the not working buttons part. The buttons are representing the four colors of the game. Some help would be much appreciated! The code I'm using:
void Update(){
if (Input.GetButtonDown("START")) {
Application.LoadLevel (2);
}
else if (Input.GetButtonDown("L")) {
Application.LoadLevel (0);
}
else if (Input.GetButtonDown("SELECT")) {
Application.LoadLevel (1);
}
}
SimonLightPlate.eType GetKey(string name){
if (Input.GetKey(KeyCode.Joystick1Button1)){
return SimonLightPlate.eType.BLUE;
}
return SimonLightPlate.eType.INVALID_TYPE;
}
void OnKeyDown() {
if (Input.GetKey(0)) {
this.SendMessageUpwards("OnLeftClickDown", GetKey(this.name), SendMessageOptions.DontRequireReceiver);
//return SimonLightPlate.eType.BLUE;
Debug.Log ("O Works");
}
}
void OnKeyUp() {
if (Input.GetKey(0)) {
this.SendMessageUpwards("OnLeftClickUp", GetKey(this.name), SendMessageOptions.DontRequireReceiver);
//return SimonLightPlate.eType.BLUE;
Debug.Log ("O Works");
}
}
//private SimonSays simonsays;
SimonLightPlate.eType GetColorPlate(string clickPlaneStr){
if (this.name == "BlueClick"){
return SimonLightPlate.eType.BLUE;
}
else if (this.name == "GreenClick"){
return SimonLightPlate.eType.GREEN;
}
else if (this.name == "RedClick"){
return SimonLightPlate.eType.RED;
}
else if (this.name == "YellowClick"){
return SimonLightPlate.eType.YELLOW;
}
else if (this.name == "PlayClick"){
Application.LoadLevel (2);
}
else if (this.name == "InstructionsClick"){
Application.LoadLevel (1);
}
else if (this.name == "BackClick"){
Application.LoadLevel (0);
}
else if (Input.GetKey(KeyCode.Joystick1Button1)) {
return SimonLightPlate.eType.BLUE;
}
//else if (Input.GetButton("V")) {
// return SimonLightPlate.eType.GREEN;
//}
//else if (Input.GetButton("T")) {
// return SimonLightPlate.eType.RED;
//}
//else if (Input.GetButton("X")) {
// return SimonLightPlate.eType.YELLOW;
//}
return SimonLightPlate.eType.INVALID_TYPE;
}
void OnMouseOver() {
if (Input.GetMouseButtonDown (0)) {
this.SendMessageUpwards("OnLeftClickDown", GetColorPlate(this.name), SendMessageOptions.DontRequireReceiver);
}
//else if (Input.GetKeyDown(0)) {
// this.SendMessageUpwards("OnLeftClickDown", GetKey(0), SendMessageOptions.DontRequireReceiver);
//}
}
void OnMouseUp() {
if (Input.GetMouseButtonUp (0)) {
this.SendMessageUpwards("OnLeftClickUp", GetColorPlate(this.name), SendMessageOptions.DontRequireReceiver);
}
//else if (Input.GetKeyUp(0)) {
// this.SendMessageUpwards("OnLeftClickUp", GetKey(0), SendMessageOptions.DontRequireReceiver);
//}
}
}
I tried to modify On$$anonymous$$ouseOver and On$$anonymous$$ouseUp(the last two parts) and so I replaced $$anonymous$$ouseButtonDown in: if (Input.Get$$anonymous$$ouseButtonDown(0)) {
with $$anonymous$$ey, because I want Gamepad input and want to use Input.Get$$anonymous$$ey to achieve that. I also tried Input.GetButton(0)
I copied the last two parts( On$$anonymous$$ouseOver and On$$anonymous$$ouseUp) and replaced Input.Get$$anonymous$$ouseButtonDown with Input.Get$$anonymous$$ey, because I want gamepad controls besides the touch/mouse controls and would like to achieve that with Get$$anonymous$$ey. I also tried Input.GetButton.