根据pico 官方给的文档进行操作即可。
按钮点击的原理是射线先获取到button,然后按下手柄A键,
button绑定方法与PC端一样;
if (Input.GetKey(KeyCode.Joystick1Button0))相当于按下鼠标左键;
按键测试代码:
if (Input.GetKey(KeyCode.Joystick1Button0)) //A
{
Debug.Log("0");
text.text = KeyCode.Joystick1Button0.ToString();
}
if (Input.GetKey(KeyCode.Joystick1Button1))//B
{
Debug.Log("1");
text.text = "1";
}
if (Input.GetKey(KeyCode.Joystick1Button2))//X
{
Debug.Log("2");
text.text = "2";
}
if (Input.GetKey(KeyCode.Joystick1Button3))//Y
{
Debug.Log("3");
text.text = "3";
}
if (Input.GetKey(KeyCode.Joystick1Button4))//L
{
Debug.Log("4");
text.text = "4";
}
if (Input.GetKey(KeyCode.Joystick1Button5))//R
{
Debug.Log("5");
text.text = "5";
}
if (Input.GetKey(KeyCode.Menu))//菜单键
{
Debug.Log("6");
text.text = KeyCode.Menu.ToString();
}
if (Input.GetKey(KeyCode.Escape))//返回键
{
text.text = KeyCode.Escape.ToString();
}
float a=Input.GetAxis("Horizontal"); 获取手柄左边左右;
float b=Input.GetAxis("Vertical"); 获取手柄左边上下方向;