Building for GearVR and Oculus Go
To build for Samsung GearVR and Oculus Go mobile devices, you will use the Oculus SDK. These are both Android-based devices so you must set up your development machine for Android development as described previously (Oculus Go is binary and compatible with GearVR). Then complete the following steps in Unity:
- Configure your Unity Build Settings to target the Android platform.
- In Player Settings, under XR Settings, set Virtual Reality Enabled
- Ensure Oculus is at the top of the Virtual Reality SDKs list.
- Download and Install the Oculus Integration package from the Asset Store, as instructed previously.
Now we will add the OVR camera rig to the MeMyselfEye object in our scene. These steps are like the Standalone Oculus Rift setup described previously. In this case, you can use the same MeMyselfEye prefab for both Rift and GearVR.
- Look in your Project window; under the Assets folder you should have a folder named OVR.
- Within that is a subfolder called Prefabs. Drag the prefab named OVRCameraRig from the Assets/OVR/Prefabs/ folder into your Hierarchy. Place it as a child object of MeMyselfEye.
- Set its height to 1.6 by setting its Transform to Position to (0, 1.6, 0).
- Disable the Main Camera object also under MeMyselfEye. You can disable objects by unchecking the enable-checkbox in the top-left of its Inspector window. Alternatively, you can just delete the Main Camera object.
- Save the prefab by selecting MeMyselfEye in Hierarchy, then press its Apply button in the Inspector.
Now, you can build your game as a separate executable app using the following steps:
- From the main menu bar, navigate to File | Build Settings...
- If the current scene is not already in the Scenes to Build list, press Add Open Scenes
- Click on Build and Run and set its name to Diorama
- I like to keep my builds in a subdirectory named Build; create one if you want to.
- Click on Save
An Android APK file will be created in your Build folder and uploaded to your attached Android device.
For more information on Unity support for Oculus SDK, see https://docs.unity3d.com/Manual/VRDevices-Oculus.html.