Focus的交互

代码测试手柄的按键功能:

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 using UnityEngine.UI;
 5 using wvr;
 6 
 7 public class testShouBing : MonoBehaviour {
 8     Text text;
 9     WVR_DeviceType devence;
10     public GameObject sphere;
11     int count = 0;
12     // Use this for initialization
13     void Start () {
14         text = GameObject.Find("Text").GetComponent<Text>();
15          devence = WVR_DeviceType.WVR_DeviceType_Controller_Right;
16     }
17     float time = 0;
18     // Update is called once per frame
19     void Update () {
20         time += Time.deltaTime;
21         if (WaveVR_Controller.Input(devence).GetPress(wvr.WVR_InputId.WVR_InputId_Alias1_Trigger))
22         {
23             text.text = "你按了Triiger键";
24 
25             sphere.transform.localScale= new Vector3(2,2,2);
26             if (time>=2)
27             {
28                 sphere.transform.localScale = new Vector3(1, 1, 1);
29                 time = 0;
30             }
31         }
32         if (WaveVR_Controller.Input(devence).GetPressDown(wvr.WVR_InputId.WVR_InputId_Alias1_Volume_Down))
33         {
34             text.text = "你按下了声音键";
35         }
36         if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetTouch(WVR_InputId.WVR_InputId_Alias1_Touchpad))
37         {
38             text.text = "你按下了圆盘键";
39             count++;
40             if (count % 2 == 0)
41             {
42                 sphere.GetComponent<MeshRenderer>().material.color = Color.red;
43             }
44             else
45             {
46                 sphere.GetComponent<MeshRenderer>().material.color = Color.blue;
47             }
48         }
49         if (WaveVR_Controller.Input(devence).GetPressDown(WVR_InputId.WVR_InputId_Alias1_DPad_Left))
50         {
51             text.text = "你触摸了圆盘的键左";
52         }
53         if (WaveVR_Controller.Input(devence).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Bumper))
54         {
55             text.text = "你按下了Bumper键";
56         }
57   
58         if (WaveVR_Controller.Input(devence).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Menu))
59         {
60             text.text = "你按下了_Menu的键";
61        
62         }
63 
64         WaveVR_Controller.Input(devence).GetAxis(WVR_InputId.WVR_InputId_Alias1_Touchpad);
65     }
66 }

 

 

HTC VIVE fORCE sdk下载网址:https://hub.vive.com/zh-CN/developer-portal

1.Unity中的小细节:如果确定是Anndroy就先改变这个

2.导入一个相机

 

3.凝视输入:看一个东西持续的时间久了,就是默认选择了这个物体,

near能看到的最近的距离,Far能看到的最远距离

 5.通过这个脚本控制手柄是否已经可以移动了,手柄,头衔都哟啊挂这个脚本

针对手柄的操作:

左边的 ctrl 控制旋转

左边的alt 左右

 6.添加手柄:

 

 代码获取手柄:

2.按键检测,事实获取

 

物体上添加这个脚本,它就自己旋转:

 

把鼠标放上去:

 

 

交互UI的时候添加这个脚本:

 

posted @ 2018-10-25 15:52  白纸菇凉  阅读(675)  评论(0编辑  收藏  举报