【Unity+Vive】第三篇:Vive Input Utility手把手教程

修改了图片位置。

原链接:

https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1728&extra=page%3D1

 

[内容相关]一款能让Vive开发变简单的插件——Vive Input Utility手把手教程

相信各位小伙伴们在使用SteamVR Unity Plugin的过程中应该都遇到过这样的问题:获取设备很麻烦,设备在重启后indexID会改变从而导致设置好的左右手设备出现交错;无法与UGUI的事件系统连接导致无法使用UGUI等等很多问题。(见图1

 
        
官方推出Vive InputUtility Unity Plugin,解决了以上的一些问题,为大家的开发提供了很好的便利。大家可以在Unity AssetStore中下载到,https://www.assetstore.unity3d.com/cn/#!/content/64219 
本插件的联络邮箱为 [email protected],如果有问题可以通过这个邮箱反馈。 

我们会推出Vive Input Utility使用教程系列, 
第一篇:Vive Input Utility的使用指南https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1708&extra=page%3D1 
第二篇:Vive Input Utility API详解https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1720&extra=page%3D1 
第三篇:Vive Input Utility手把手教程https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1728&extra=page%3D1 

手把手教你用Vive Input Utility,跟着下面的步骤一步步操作,让你的程序非常迅速的适配Vive的操作。 

第一步(见图2 
使用SteamVR Unity插件搭建支持VR的基本场景。 



第二步(见图3 
创建并选择你的right hand object 
点击“Add Component”添加VivePoseTracker脚本。 



第三步(见图4 
VivePoseTrackerorigin变量设置为VR camera 
role设置为右手。 



第四步(见图5 
你可以隐藏你的模型,当设备失去追踪或者连接中断; 
如下设置: 
        1.
点击+号,给On Is Valid Changed增加一项; 
        2.
将你的模型对象拖到这项上; 
        3.
选择回调函数为SetActive 



第五步(见图6 
创建并选择你的laser pointer object 
点击“Add Component”添加ViveRaycaster脚本。 



第六步(见图7 
设置按钮事件源为"Right Hand Only" 



第七步(见图8 
重复第四步,但是这次将laser pointer object拖到新的回调项中。 



第八步(见图9 
右击right hand object,点击"Duplicate"复制。 



第九步(见图10 
选择复制了的对象,并重命名为"Left Hand"作为left hand object 



第十步(见图11 
VivePoseTracker脚本中设置role为左手。 



第十一步(见图12 
选择 left hand object中的laser pointerobject 
ViveRaycaster脚本中设置按钮事件源为"Left HandOnly"

 

第十二步(见图13 
hierarchy中创建一个UI按钮。

 

第十三步(见图14 
移除默认的事件系统对象; 
选择默认画布; 
移除canvas scalar component 
移除graphic raycaster component 
设置渲染模式为"World Space" 



第十四步(见图15 
点击“Add Component”添加CanvasRaycastTarget脚本。 



第十五步(见图16/17 
设置画布上的rect,并将它放到 VR camera的视野里面 




完成!(见图18 



UGUI
现在监测到vive controller产生的事件了! 
你可以在Asset/HTC.UnityPlugin/ViveInputUtility/Examples/0.Tutorial中找到本场景。 


        本帖最后由 Shengjie Zhang 2016-9-1 11:00编辑 

猜你喜欢

转载自blog.csdn.net/obarong/article/details/52504822