Skip to content

Instantly share code, notes, and snippets.

@lyokato
Last active May 22, 2018 17:36
Show Gist options
  • Save lyokato/5735c7265dbb916807884716a8054299 to your computer and use it in GitHub Desktop.
Save lyokato/5735c7265dbb916807884716a8054299 to your computer and use it in GitHub Desktop.
OVRPose tracker = OVRManager.tracker.GetPose();
trackerAnchor.localRotation = tracker.orientation;
#if UNITY_EDITOR_OSX
// OS X Editorの時は、カメラの向き設定を差し替える
centerEyeAnchor.localRotation = OVROSX.JoyconTracker.Instance.GetLeftOrientation();
leftEyeAnchor.localRotation = centerEyeAnchor.localRotation;
rightEyeAnchor.localRotation = centerEyeAnchor.localRotation;
#elif UNITY_2017_2_OR_NEWER
centerEyeAnchor.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye);
leftEyeAnchor.localRotation = monoscopic ? centerEyeAnchor.localRotation : UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftEye);
rightEyeAnchor.localRotation = monoscopic ? centerEyeAnchor.localRotation : UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightEye);
#else
centerEyeAnchor.localRotation = UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.CenterEye);
leftEyeAnchor.localRotation = monoscopic ? centerEyeAnchor.localRotation : UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.LeftEye);
rightEyeAnchor.localRotation = monoscopic ? centerEyeAnchor.localRotation : UnityEngine.VR.InputTracking.GetLocalRotation(UnityEngine.VR.VRNode.RightEye);
#endif
#if UNITY_EDITOR_OSX
// OS X Editorのときは、コントローラの向き設定を差し替える。
// RTrackedRemoteしか使わなければrightHandだけ差し替えれば良い。
leftHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
rightHandAnchor.localRotation = OVROSX.JoyconTracker.Instance.GetRightOrientation();
#else
leftHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
rightHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment