Unity屏蔽Oculus陀螺仪

 时间:2024-10-15 05:03:13

1、打开Unity,PlayerSetting设置虚拟现实技术支持,勾选Oculus。

Unity屏蔽Oculus陀螺仪

2、连接Oculus头盔,并打开Oculus应用,设置允许未知来源(unknown sources)使用

Unity屏蔽Oculus陀螺仪

3、导入OculusUtilities插件,然后Unity中会多两个文件夹,分别为OVR和Plugins。

Unity屏蔽Oculus陀螺仪

4、在OVR中找到Scenes文件夹,打开Cubes场景

Unity屏蔽Oculus陀螺仪

5、创建FakeTracking脚本,代码如下:using UnityEngine;using System.Col造婷用痃lections;public class FakeTracking : MonoBehaviour { public OVRPose centerEyePose = OVRPose.identity; public OVRPose leftEyePose = OVRPose.identity; public OVRPose rightEyePose = OVRPose.identity; public OVRPose leftHandPose = OVRPose.identity; public OVRPose rightHandPose = OVRPose.identity; public OVRPose trackerPose = OVRPose.identity; void Awake() { OVRCameraRig rig = GameObject.FindObjectOfType<OVRCameraRig>(); if (rig != null) rig.UpdatedAnchors += OnUpdatedAnchors; } void OnUpdatedAnchors(OVRCameraRig rig) { if (!enabled) return; //This doesn't work because VR camera poses are read-only. //rig.centerEyeAnchor.FromOVRPose(OVRPose.identity); //Instead, invert out the current pose and multiply in the desired pose. OVRPose pose = rig.centerEyeAnchor.ToOVRPose(true).Inverse(); pose = centerEyePose * pose; rig.trackingSpace.FromOVRPose(pose, true); //OVRPose referenceFrame = pose.Inverse(); //The rest of the nodes are updated by OVRCameraRig, not Unity, so they're easy. //forums.oculus.com/vip/discussion/comment/446956/ rig.leftEyeAnchor.FromOVRPose(leftEyePose); rig.rightEyeAnchor.FromOVRPose(rightEyePose); rig.leftHandAnchor.FromOVRPose(leftHandPose); rig.rightHandAnchor.FromOVRPose(rightHandPose); rig.trackerAnchor.FromOVRPose(trackerPose); }}

6、将FakeTracking脚本挂载到与OVRManager脚本同一个物体下

Unity屏蔽Oculus陀螺仪

7、佩戴Oculus头盔,运行项目,此时场景画面将不会随么Oculus旋转而旋转,如果会发现Oculus显示的画面会有点抖动,这个官方暂时还无法解决。

  • 易语言如何修改标签的文字描述
  • 无主之地1 怎么选择武器
  • 雷电模拟器如何设置手机版dpi分辨率
  • 王国风云2怎么召唤雇佣兵
  • 安卓MTK手机,用SN_STATION永久写入IMEI方法。
  • 热门搜索
    苏康码怎么弄 吉他怎么调音 爱心怎么折 牙神经痛怎么办 怎么制作视频短片 朋友圈怎么发文字 凉拌菜花的做法 莴笋怎么做好吃 微博怎么注销 怎么注销微博