Trying to figure out why this project is not detecting my controller. I have a regular Unity project I use as a base project for all my games. The controller tester works but when I imported it into my Mirror project. It does not work. Mirror is the only different factor I can see. Hoping someone else has seen this before?
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WBG_Controller_Settings : MonoBehaviour
{
//Controller
public Image ctr_Left;
public Image ctr_Right;
public Image padLeft;
public Image padUp;
public Image padRight;
public Image padDown;
public Image ctrSelect;
public Image ctrStart;
public Image ctr_1;
public Image ctr_2;
public Image ctr_3;
public Image ctr_4;
//Keyboard
public Image key_W;
public Image key_A;
public Image key_S;
public Image key_D;
public Image key_Space;
//Keypad
public Image key_Up;
public Image key_Down;
public Image key_Left;
public Image key_Right;
private Color32 _clrRed = new Color32(96, 245, 227, 255);
private Color32 _clrRed2 = new Color32(255, 0, 0, 255);
private Color32 _clrWhite = new Color32(255, 255, 255, 255);
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
if (horizontalInput == -1)
{
padLeft.color = _clrRed;
}
else if(horizontalInput == 1)
{
padRight.color = _clrRed;
}
else
{
padLeft.color = _clrWhite;
padRight.color = _clrWhite;
}
if (verticalInput == -1)
{
padDown.color = _clrRed;
}
else if (verticalInput == 1)
{
padUp.color = _clrRed;
}
else
{
padDown.color = _clrWhite;
padUp.color = _clrWhite;
}
foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
{
//Keypress Method
if (Input.GetKeyDown(kcode))
{
switch (kcode)
{
//Controller
//Button 1
case KeyCode.Joystick1Button3:
ctr_1.color = _clrRed;
break;
//Button 2
case KeyCode.Joystick1Button0:
ctr_2.color = _clrRed;
break;
//Button 3
case KeyCode.Joystick1Button2:
ctr_3.color = _clrRed;
break;
//Button 4
case KeyCode.Joystick1Button1:
ctr_4.color = _clrRed;
break;
//Left
case KeyCode.Joystick1Button4:
ctr_Left.color = _clrRed2;
break;
//Right
case KeyCode.Joystick1Button5:
ctr_Right.color = _clrRed2;
break;
//Select
case KeyCode.Joystick1Button8:
ctrSelect.color = _clrRed;
break;
//Start
case KeyCode.Joystick1Button9:
ctrStart.color = _clrRed;
break;
case KeyCode.W:
key_W.color = _clrRed;
break;
case KeyCode.A:
key_A.color = _clrRed;
break;
case KeyCode.S:
key_S.color = _clrRed;
break;
case KeyCode.D:
key_D.color = _clrRed;
break;
case KeyCode.Space:
key_Space.color = _clrRed;
break;
//Keypad
case KeyCode.DownArrow:
key_Down.color = _clrRed;
break;
case KeyCode.UpArrow:
key_Up.color = _clrRed;
break;
case KeyCode.LeftArrow:
key_Left.color = _clrRed;
break;
case KeyCode.RightArrow:
key_Right.color = _clrRed;
break;
}
}
else if (Input.GetKeyUp(kcode))
{
switch (kcode)
{
//Controller
//Button 1
case KeyCode.Joystick1Button3:
ctr_1.color = _clrWhite;
break;
//Button 2
case KeyCode.Joystick1Button0:
ctr_2.color = _clrWhite;
break;
//Button 3
case KeyCode.Joystick1Button2:
ctr_3.color = _clrWhite;
break;
//Button 4
case KeyCode.Joystick1Button1:
ctr_4.color = _clrWhite;
break;
//Left
case KeyCode.Joystick1Button4:
ctr_Left.color = _clrWhite;
break;
//Right
case KeyCode.Joystick1Button5:
ctr_Right.color = _clrWhite;
break;
//Select
case KeyCode.Joystick1Button8:
ctrSelect.color = _clrWhite;
break;
//Start
case KeyCode.Joystick1Button9:
ctrStart.color = _clrWhite;
break;
//Keyboard
case KeyCode.W:
key_W.color = _clrWhite;
break;
case KeyCode.A:
key_A.color = _clrWhite;
break;
case KeyCode.S:
key_S.color = _clrWhite;
break;
case KeyCode.D:
key_D.color = _clrWhite;
break;
case KeyCode.Space:
key_Space.color = _clrWhite;
break;
//Keypad
case KeyCode.DownArrow:
key_Down.color = _clrWhite;
break;
case KeyCode.UpArrow:
key_Up.color = _clrWhite;
break;
case KeyCode.LeftArrow:
key_Left.color = _clrWhite;
break;
case KeyCode.RightArrow:
key_Right.color = _clrWhite;
break;
}
}
}
}
}
All this does is “lights” up a image when a button is pressed to test your keyboard or controller. In my standard unity project it works fine no issues. In this mirror game, it detects nothing. Even set break points. No keys are detected ever on the controller. Keyboard still works just not controllers.
