// Use this function for procedural rendering // Gets called twice per frame, once for each eye. // On each frame, left eye renders before right eye so // we keep track of a boolean that toggles back and forth // between each eye. private void OnRenderObject() { if (keyboardProvider == null || !IsReady) { return; } #if UNITY_ANDROID Camera camera = Camera.current; if (camera && camera == Camera.main) { // Get current eye. Camera.StereoscopicEye camEye = isRight ? Camera.StereoscopicEye.Right : Camera.StereoscopicEye.Left; // Camera matrices. Matrix4x4 proj = camera.GetStereoProjectionMatrix(camEye); Matrix4x4 modelView = camera.GetStereoViewMatrix(camEye); // Camera viewport. Rect viewport = camera.pixelRect; // Render keyboard. keyboardProvider.Render((int)camEye, modelView, proj, viewport); // Swap. isRight = !isRight; } #endif // !UNITY_ANDROID }
// Use this function for procedural rendering // Gets called twice per frame, once for each eye. // On each frame, left eye renders before right eye so // we keep track of a boolean that toggles back and forth // between each eye. void OnRenderObject() { if (keyboardProvider == null || !IsReady) { return; } #if UNITY_HAS_GOOGLEVR Camera camera = Camera.current; if (camera && camera == Camera.main) { // Get current eye. Camera.StereoscopicEye camEye = isRight ? Camera.StereoscopicEye.Right : Camera.StereoscopicEye.Left; // Camera matrices. Matrix4x4 proj = camera.GetStereoProjectionMatrix(camEye); Matrix4x4 modelView = camera.GetStereoViewMatrix(camEye); // Camera viewport. Rect viewport = camera.pixelRect; // Render keyboard. keyboardProvider.Render((int)camEye, modelView, proj, viewport); // Swap. isRight = !isRight; } #else Debug.LogWarning("Keyboard is not supported in versions of Unity without the native integration"); #endif // !UNITY_HAS_GOOGLEVR }