1、首先创建VRScripts空物体,用来存放脚本,在其下创建Right空物体并添加VRTK_ControllerEvents脚本

2、Right作为右手手柄,拖拽到[VRTK_SDKManager]的RightController上

3丶在Right上新建脚本RightController,通过得到VRTK_ControllerEvents组件注册方法,就可以监听到按下手柄哪些键了

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;// 引用VRTK命名空间 public class RightController: MonoBehaviour
{
private VRTK_ControllerEvents controllerEvents;
private void Awake()
{
controllerEvents = GetComponent<VRTK_ControllerEvents>();
// 输入+=后按Tab键后自动补全方法
controllerEvents.TouchpadPressed += ControllerEvents_TouchpadPressed;
controllerEvents.TouchpadReleased += ControllerEvents_TouchpadReleased;
controllerEvents.GripPressed += ControllerEvents_GripPressed;
} private void ControllerEvents_GripPressed(object sender, ControllerInteractionEventArgs e)
{
Debug.Log("抓取键按下");
} private void ControllerEvents_TouchpadReleased(object sender, ControllerInteractionEventArgs e)
{
Debug.Log("圆盘键按释放");
} private void ControllerEvents_TouchpadPressed(object sender, ControllerInteractionEventArgs e)
{
Debug.Log("圆盘键按下");
}
}

还有许多方法这里不逐条列出,大家自行查看VRTK_ControllerEvents脚本

4丶注意:只要涉及到操作手柄,就必须要添加VRTK_ControllerEvents脚本

最新文章

  1. [LeetCode] Insertion Sort List 链表插入排序
  2. cannot simultaneously fetch multiple bags
  3. Java基础(42):Java中主类中定义方法加static和不加static的区别(前者可以省略类名直接在主方法调用,后者必须先实例化后用实例调用)
  4. python 基础学习(字典对象,set对象)
  5. python之---类和实例
  6. 转:Git_Windows 系统下Git安装图解
  7. android的intent打开系统程序
  8. [ACM] POJ 3273 Monthly Expense (二分解决最小化最大值)
  9. 使用elk+redis搭建nginx日志分析平台(转)
  10. Android 动画的分类
  11. recycleView 使用指南1
  12. Collections模块下的Counter
  13. C#一句话判断两个List&lt;T&gt;是否相等
  14. 多个子域名前端网站调用同一个webAPI时session混用问题
  15. C#-多态(十二)
  16. [JOI2017/2018]美術展
  17. Python3字典
  18. POJ - 3122 Pie(二分)
  19. Java中使用FileputStream导致中文乱码问题的修改方案
  20. 在Spark上运行TopK程序

热门文章

  1. python的tkinter对话框
  2. openfire开发环境(3.9.1)
  3. Linux下Fork与Exec
  4. Xcode 中的main.m
  5. js动态加载activeX控件在IE11与低版本IE中的差异
  6. BZOJ3165:[HEOI2013]Segment
  7. AGC600 C Rabbit Exercise —— 置换
  8. VijosP1626:爱在心中
  9. POJ1986(LCA应用:求两结点之间距离)
  10. DCloud-HTML5+:barcode