【Unity+Vive】第二篇:Vive Input Utility API详解

来源:互联网 发布:安卓网络管理软件 编辑:程序博客网 时间:2024/05/16 16:11

修改了图片位置。

原链接:

https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1720

 

一款能让Vive开发变得简单的插件——Vive Input Utility API详解

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


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

我们会推出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 

API
详解: 
uint ViveRole.GetDeviceIndex(DeviceRole role)
 
        
返回由role确定的设备的设备索引,如果role没有分配任何设备的话返回OpenVR.k_unTrackedDeviceIndexInvalid 
bool VivePose.HasFocus()
 
        
返回true,如果当进程正在运行。通常当玩家按下手柄上菜单按钮切换到steam菜单面板时,进程切换到后台。 
bool VivePose.IsConnected(DeviceRole role)
 
        
如果由role定义的设备被连接了返回true 
bool VivePose.HasTracking(DeviceRole role)
 
        
如果由role定义的设备的追踪数据有有效值的时候返回true 
Pose VivePose.GetPose(DeviceRole role, Transform origin = null)
 
        
返回由role定义的设备的追踪pose 
void VivePose.SetPose(Transform target, DeviceRole role, Transform origin =null)
 
        
设置目标pose来追踪由role定义的设备的相对于originpose 
bool ViveInput.GetPress(HandRole role, ControllerButton button)
 
        
当控制器上的按钮被按了的时候返回true 
bool ViveInput.GetPressDown(HandRole role, ControllerButton button)
 
        
当控制器上的按钮被按下的时候返回true 
bool ViveInput.GetPressUp(HandRole role, ControllerButton button)
 
        
当控制器上的按钮被松开的时候返回true 
float ViveInput.GetTriggerValue(HandRole role)
 
        
返回扳机键的原始的模拟量 
Vector2 ViveInput.GetPadAxis(HandRole role)
 
        
返回touchpad上的原始模拟量 
int ViveInput.ClickCount(HandRole role, ControllerButton button)
 
        
返回按钮连续点击的次数。查看ViveInput.clickInterval来获取点击间隔时间 
float ViveInput.LastPressDownTime(HandRole role, ControllerButton button)
 
      
返回用户按下按钮的最后一帧的时间 
void ViveInput.AddPress(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.AddPressDown(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.AddPressUp(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.AddClick(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.RemovePress(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.RemovePressDown(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.RemovePressUp(HandRole role, ControllerButton button, Actioncallback)
 
void ViveInput.RemoveClick(HandRole role, ControllerButton button, Actioncallback)
 
        
添加和移除presspressdownpressupclick的监听事件 
void ViveInput.TriggerHapticPulse(HandRole role, ushort intensity = 500)
 
        
控制器上扳机的震动 


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

0 0
原创粉丝点击