Unity 5.1 onwards contains built-in support for certain VR devices.
VR has traditionally been supported in Unity via external plugins. This had a few shortcomings:
Unity VR adds the ability to target VR devices from directly within Unity without the need for external plugins. It provides a base API and featureset with the goal of forward compatibility for devices and software. The provided API surface today is minimal by design, and will expand as we learn more about the needs of VR developers.
To enable VR for your game builds and the editor, set the “Virtual Reality Supported” option in Player Settings.
When VR is enabled in Unity, a few things happen automatically for you:
The option to start in VR mode is saved per computer, and defaults as VR off at the moment. This will change in the future.
To choose a VR Device, you can start Unity or the Unity application with the following command line argument:
-vrmode DEVICETYPE
where DEVICETYPE is one of the names from the supported VR devices list. Ex.
Game.exe -vrmode oculus
Or, you can request a VR Device be loaded at runtime by setting the loaded device.
Once a VR device is loaded (loadedDevice returns something other than None), you can enable VR globally and start rendering to your device by setting VR.VRSettings.enabled to true.
VRDevice.family is a string corresponding to the current VRSettings.loadedDevice. A family can have multiple models which have different characteristics. For example: Oculus has DK2, Gear VR, etc. The model can be accessed with VRDevice.model.