protected void Update() { if (_shouldSetLocalPosition) { transform.localPosition = transform.forward * _deviceInfo.forwardOffset; _shouldSetLocalPosition = false; } if (Input.GetKeyDown(_recenter) && XRSupportUtil.IsXREnabled() && XRSupportUtil.IsXRDevicePresent()) { XRSupportUtil.Recenter(); } // Manual Time Alignment if (_allowManualTimeAlignment) { if (_unlockHold == KeyCode.None || Input.GetKey(_unlockHold)) { if (Input.GetKeyDown(_moreRewind)) { _customWarpAdjustment += 1; } if (Input.GetKeyDown(_lessRewind)) { _customWarpAdjustment -= 1; } } } }
public void UpdateOrderGivenComponent(Component component) { if (Application.isPlaying) { return; } //Allow the user to specify themselves if VR is disabled. if (!XRSupportUtil.IsXREnabled()) { return; } Camera camera = component.GetComponent <Camera>(); if (camera == null) { camera = component.gameObject.AddComponent <Camera>(); } SerializedObject obj = new SerializedObject(camera); SerializedProperty targetEyeProp = obj.FindProperty(TARGET_EYE_PROPERTY_NAME); OrderType newOrder = (OrderType)targetEyeProp.intValue; if (_orderType != newOrder) { _orderType = newOrder; EditorUtility.SetDirty(component); } }
protected void LateUpdate() { if (_forceCustomUpdate) { ManuallyUpdateTemporalWarping(); } else if (XRSupportUtil.IsXREnabled()) { updateTemporalWarping(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); } }
private void onValidCameraParams(LeapVRCameraControl.CameraParams cameraParams) { _projectionMatrix = cameraParams.ProjectionMatrix; if (XRSupportUtil.IsXREnabled()) { if (provider != null) { updateHistory(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); } if (_syncMode == SyncMode.LOW_LATENCY) { updateTemporalWarping(XRSupportUtil.GetXRNodeCenterEyeLocalPosition(), XRSupportUtil.GetXRNodeCenterEyeLocalRotation()); } } }
private bool checkShouldEnableHeadMounted() { if (XRSupportUtil.IsXREnabled()) { var parentCamera = GetComponentInParent <Camera>(); if (parentCamera != null && parentCamera.stereoTargetEye != StereoTargetEyeMask.None) { if (!_isHeadMounted) { if (Application.isPlaying) { Debug.LogError("VR is enabled and the LeapServiceProvider is the child of a " + "camera targeting one or both stereo eyes; You should " + "check the isHeadMounted option on the LeapServiceProvider " + "if the Leap is mounted or attached to your VR headset!", this); } return(true); } } } return(false); }
public static Quaternion GetXRNodeHeadLocalRotation() { #if SVR if (SvrManager.Instance != null) { if (XRSupportUtil.IsXREnabled()) { return(SvrManager.Instance.head.transform.localRotation); } else { Debug.LogWarning("Cannot read XRNodeHeadLocalRotation as XR is not enabled"); return(Quaternion.identity); } } #endif #if UNITY_2019_2_OR_NEWER InputTracking.GetNodeStates(nodeStates); Quaternion rotation; foreach (XRNodeState state in nodeStates) { if (state.nodeType == XRNode.Head && state.TryGetRotation(out rotation)) { return(rotation); } } return(Quaternion.identity); #elif UNITY_2017_2_OR_NEWER return(InputTracking.GetLocalRotation(XRNode.Head)); #else return(InputTracking.GetLocalRotation(VRNode.Head)); #endif }
public static Vector3 GetXRNodeHeadLocalPosition() { #if SVR if (SvrManager.Instance != null) { if (XRSupportUtil.IsXREnabled()) { return(SvrManager.Instance.head.localPosition); } else { Debug.LogWarning("Cannot read XRNodeHeadLocalPosition as XR is not enabled"); return(Vector3.zero); } } #endif #if UNITY_2019_2_OR_NEWER InputTracking.GetNodeStates(nodeStates); Vector3 position; foreach (XRNodeState state in nodeStates) { if (state.nodeType == XRNode.Head && state.TryGetPosition(out position)) { return(position); } } return(Vector3.zero); #elif UNITY_2017_2_OR_NEWER return(InputTracking.GetLocalPosition(XRNode.Head)); #else return(InputTracking.GetLocalPosition(VRNode.Head)); #endif }