iosunity-game-enginegoogle-cardboardgoogle-vr-sdk

Creating singular view in Unity using GoogleVR ( GoogleCardboard ) for iOS


I am a college student attempting to build a VR application for iOS using Unity paired with GoogleVR sdk (Google Cardboard). I can get my app to run on an iPad, but the display on the screen is through two viewports (or cameras, not sure the correct terminology) for two eyes.

While this may be contradictory to the idea of VR, I actually only want a single central camera's perspective and for that display to fill the whole screen.

I've been searching through the Unity project files and the google Cardboard files, but haven't found a way to do this. Is there a simple way to turn off the two eye display and instead do a single view? If so, what file would I modify?

Thanks!


Solution

  • The main things that the Cardboard SDK give you on iOS is stereoscopic rendering, control of camera rotation based on the gyroscope, and the gaze pointer. If you don't want stereoscopic rendering, you can disable VR support in XR Settings and use some simple replacements for the other two items. You can add a regular camera to your scene and then use a script like this to set its rotation based on the phone's gyroscope:

    using UnityEngine;
    
    class SceneManager : MonoBehaviour {
    
        void Start() {
    
            // Enable the gyro so that it can be used to control the camera rotation.
            Input.gyro.enabled = true;
        }
    
        void Update() {
    
            // Update the camera rotation based on the gyroscope.
            Camera.main.transform.Rotate(
                -Input.gyro.rotationRateUnbiased.x,
                -Input.gyro.rotationRateUnbiased.y,
                Input.gyro.rotationRateUnbiased.z
            );
        }
    }
    

    To replace the gaze pointer, you can use Unity's standalone input module to route screen touch events through the input system (e.g. to trigger scripts that implement IPointerClickHandler).