鉴于某些手机在使用大朋SDK以及谷歌SDK时会出现神器的小屏现象(比如某想的)故为了能够最大程度的兼容更多的手机,决定使用暴风魔镜的SDK。废话不多说~直接将使用暴风魔镜SDK时遇到的问题以及解决方案简单的罗列一下:
在暴风魔镜的官网下载了最新的SDK后导入Unity项目,发现SDK中的DEMO全部是非手柄控制的,然后只能参照着SDK里面的接口说明文档自己研究~~结果发现接口文档非一般的坑,一开始是直接在MojingInputManager.cs里面直接填充,直到最后才发现用IntegrateInputManager.prefab替换场景中原有的MojingInputManager.prefab以后就可以跟检测Unity的输入一样检测到手柄的输入了,以下为源码(详情可直接参考接口文档3.9节):
[csharp] view plain copy //摇杆上移 if (CrossPlatformInputManager.GetButtonDown("UP")) { Debug.LogWarning("Up_Get"); up = 1; } //摇杆下移 if (CrossPlatformInputManager.GetButtonDown("DOWN")) { Debug.LogWarning("Down_Get"); up = -1; } //摇杆右移 if (CrossPlatformInputManager.GetButtonDown("RIGHT")) { Debug.LogWarning("Right_Get"); right = 1; } //摇杆左移 if (CrossPlatformInputManager.GetButtonDown("LEFT")) { Debug.LogWarning("Left_Get"); right = -1; } //摇杆回到中间位置 if (CrossPlatformInputManager.GetButton("CENTER")) { Debug.LogWarning("CENTER_Get"); up = 0; right = 0; } //按下确定(OK)键 if (CrossPlatformInputManager.GetButtonDown("OK")) { Debug.LogWarning("OK_Get"); } //按下取消键 if (CrossPlatformInputManager.GetButtonDown("C")) { Debug.LogWarning("Cancle_Get"); } //按下菜单键 if (CrossPlatformInputManager.GetButtonDown("MENU")) { Debug.LogWarning("MENU_Get"); }
http://blog.csdn.net/u013032852/article/details/51514162