void LateUpdate() { // to this only once per frame, not for both cameras if (IsLeft) { if (mLeftCameraDataAcquired && mRightCameraDataAcquired) { // make sure the central anchor point is set to the latest head tracking pose: DigitalEyewearBehaviour.Instance.CentralAnchorPoint.localRotation = mLeftCamera.transform.localRotation; DigitalEyewearBehaviour.Instance.CentralAnchorPoint.localPosition = mLeftCamera.transform.localPosition; // temporarily set the primary and secondary cameras to their offset position and set the pixelrect they will have for rendering Vector3 localPosLeftCam = mLeftCamera.transform.localPosition; Rect leftCamPixelRect = mLeftCamera.pixelRect; Vector3 leftCamOffset = mLeftCamera.transform.right.normalized * mLeftCamera.stereoSeparation * -0.5f; mLeftCamera.transform.position = mLeftCamera.transform.position + leftCamOffset; mLeftCamera.pixelRect = mLeftCameraPixelRect; Vector3 localPosRightCam = mRightCamera.transform.localPosition; Rect rightCamPixelRect = mRightCamera.pixelRect; Vector3 rightCamOffset = mRightCamera.transform.right.normalized * mRightCamera.stereoSeparation * 0.5f; mRightCamera.transform.position = mRightCamera.transform.position + rightCamOffset; mRightCamera.pixelRect = mRightCameraPixelRect; BackgroundPlaneBehaviour bgPlane = mLeftCamera.GetComponentInChildren <BackgroundPlaneBehaviour>(); bgPlane.BackgroundOffset = mLeftCamera.transform.position - DigitalEyewearBehaviour.Instance.CentralAnchorPoint.position; mLeftExcessAreaBehaviour.PlaneOffset = mLeftCamera.transform.position - DigitalEyewearBehaviour.Instance.CentralAnchorPoint.position; mRightExcessAreaBehaviour.PlaneOffset = mRightCamera.transform.position - DigitalEyewearBehaviour.Instance.CentralAnchorPoint.position; if (TrackableParent != null) { TrackableParent.localPosition = Vector3.zero; } // update Vuforia explicitly VuforiaBehaviour.Instance.UpdateState(false, true); if (TrackableParent != null) { TrackableParent.position += bgPlane.BackgroundOffset; } // set the projection matrices for skewing VuforiaBehaviour.Instance.ApplyCorrectedProjectionMatrix(mLeftCameraMatrixOriginal, true); VuforiaBehaviour.Instance.ApplyCorrectedProjectionMatrix(mRightCameraMatrixOriginal, false); #if !(UNITY_5_2 || UNITY_5_1 || UNITY_5_0) // UNITY_5_3 and above // read back the projection matrices set by Vuforia and set them to the stereo cameras // not sure if the matrices would automatically propagate between the left and right, so setting it explicitly twice mLeftCamera.SetStereoProjectionMatrices(mLeftCamera.projectionMatrix, mRightCamera.projectionMatrix); mRightCamera.SetStereoProjectionMatrices(mLeftCamera.projectionMatrix, mRightCamera.projectionMatrix); #endif // reset the left camera mLeftCamera.transform.localPosition = localPosLeftCam; mLeftCamera.pixelRect = leftCamPixelRect; // reset the position of the right camera mRightCamera.transform.localPosition = localPosRightCam; mRightCamera.pixelRect = rightCamPixelRect; } } }