- Home /
Get Joystick names never refreshed on disconnect
Hi there again,
I don't know if anyone of you have encountered the problem whereby unity continues to think that a controller is still connected even after you disconnect it? When I start the project again it's refreshed to 0 but when I disconnect a controller during current session, it seems to think their is still one plugged in when I call the Input.GetJoystickNames() method. Reading about this online, I thought this was something that was being looked into? Anyone know anything of this?
void Update() {
// Before Controller Connection
string[] names = Input.GetJoystickNames();
Debug.Log("Controllers Connected: " + names.Length); // This shows as 0
// After Controller Connection
string[] names = Input.GetJoystickNames();
Debug.Log("Controllers Connected: " + names.Length); // This shows as 1
// After Controller Disconnect
string[] names = Input.GetJoystickNames();
Debug.Log("Controllers Connected: " + names.Length); // This shows as 1 (still)
}
The same thing happens when multiple controllers are connected. I think the new Patch 5.3.1 has broke it as I remembered this worked before?
Are you talking about Android or iOS? If so, yes, that's how it is right now.
I'm talking about windows PC standalone; in the process of connecting xbox 360 controllers, but it appears the problem is much wider spread.
Crosslinking this to similar question with partial workaround for windows OS: http://answers.unity3d.com/questions/1100642/joystick-runtime-plugunplug-detection.html
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Input.GetAxis returning nonsensical values for HID Sensor/GameController 0 Answers
Problems with joystick / controller axes being 1/-1 "way too often" 1 Answer
Getting input from joystick number X 0 Answers
Joystick count limit 1 Answer