unity3d与android开发真实手柄连接
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了unity3d与android开发真实手柄连接,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2566字,纯文字阅读大概需要4分钟。
内容图文
尝试过AS转写手柄监听、incontrol插件,最终没能实现。手柄型号:SP3/PC。
经过一夜奋战,通过https://blog.csdn.net/lengyoumo/article/details/91386404文章指示,
在edit ->projectsettings->input->axes中设定
type 选择joystick axis
axis 选择 x axis 和 y axis 。分别对应 horizontal 和 vertical。
如果手柄有多个摇杆,需要修改name和 axis。
修改了Dead、Sensitivity的值,不然转的头晕,速度太快,而且人物不停的朝一个方向转。。。把Vertical做了镜像(invert),好像这个轴跟U3d的3rdCControler方向是反的。Horizontal就不用了。
通过https://blog.csdn.net/cordova/article/details/51036547的方法进行了测试,目前代码如下:
public class TVInput : MonoBehaviour { public Text KeyCodeText; //显示按键状态的text文本public Text KeyCodeText1; privatebool isOk; //确定键按下状态 // 初始化void Start() { isOk = false; } // 按帧刷新检测void Update() { //监听按键事件: //*** 按下 ***////左if (Input.GetKeyDown(KeyCode.LeftArrow)) { isLeft = true; KeyCodeText.text = "左键按下"; } //右if (Input.GetKeyDown(KeyCode.RightArrow)) { isRight = true; KeyCodeText.text = "右键按下"; } //上if (Input.GetKeyDown(KeyCode.UpArrow)) { isUp = true; KeyCodeText.text = "上键按下"; } //下if (Input.GetKeyDown(KeyCode.DownArrow)) { isDown = true; KeyCodeText.text = "下键按下"; } //返回if (Input.GetKeyDown(KeyCode.Escape)) { isBack = true; KeyCodeText.text = "返回键按下"; } //回车if (Input.GetKeyDown(KeyCode.JoystickButton0)) //A { isOk = true; KeyCodeText.text = "JoystickButton0按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton1)) //B { isOk = true; KeyCodeText.text = "JoystickButton1按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton2)) //X { isOk = true; KeyCodeText.text = "JoystickButton2按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton3)) //Y { isOk = true; KeyCodeText.text = "JoystickButton3按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton4)) //L1 { isOk = true; KeyCodeText.text = "JoystickButton4按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton5)) //R1 { isOk = true; KeyCodeText.text = "JoystickButton5按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton6)) //L2 { isOk = true; KeyCodeText.text = "JoystickButton6按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton7)) //R2 { isOk = true; KeyCodeText.text = "JoystickButton7按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton8)) //左摇杆 { isOk = true; KeyCodeText.text = "JoystickButton8按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton9)) //右摇杆 { isOk = true; KeyCodeText.text = "JoystickButton9按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton10)) //START { isOk = true; KeyCodeText.text = "JoystickButton10按下"; } if (Input.GetKeyDown(KeyCode.JoystickButton11)) //SELECT { isOk = true; KeyCodeText.text = "JoystickButton11按下"; } } }
在电视端测试通过。
Stationary Turn Speed 减到20,这转速还是太快。
原文:https://www.cnblogs.com/guaike01/p/13245745.html
内容总结
以上是互联网集市为您收集整理的unity3d与android开发真实手柄连接全部内容,希望文章能够帮你解决unity3d与android开发真实手柄连接所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。