- Home /
How do I see which gamepad button names are being pressed?
There is the following page, but maybe the mapping is not correct for me. For example, I can open Edit -> Project Settings -> Input, find "Jump" and set it to "joystick button 0" but then Input.GetButtonDown("Jump")
in Update()
never returns true.
https://wiki.unity3d.com/index.php/Xbox360Controller#Buttons
Is there a way to instead print all input events and their names that unity gets so I don't have to use trial and error?
Answer by heuristic42 · Jan 20, 2020 at 06:08 AM
I've found this snippet does the job.
if (m_logInput){
foreach(KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKeyDown(kcode))
Debug.Log("KeyCode down: " + kcode);
}
}
(adding [SerializeField] bool m_logInput = false;
to the class so it can be toggled)
Thank you, This helped me out with a little problem I had!
For anyone else, be sure to add using System;
atop your code. otherwise "Enum" in "Enum.GetValues" won't be recognized.
(@heuristic42, maybe update the answer for future people to see?)
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Microsoft Surface Pen working in editor, but not build 2 Answers
Baffling Input.Mouseposition problem. If statement not correctly working. 1 Answer
Vive Controller not enabled until mouse click 0 Answers
Collision Not Working 1 Answer