Unity VR lets you target virtual reality devices directly from Unity, without any external plug-ins in projects. It provides a base API and feature set with compatibility for multiple devices. It has been designed to provide forward compatibility for future devices and software.
Note: XR is an umbrella term which encompassess virtual reality (VR), augmented reality (AR), and other similar technologies. We are in the process of updating our XR documentation, but for now this documentation refers mainly to just VR.
Unity’s XR API has been updated to reflect the broader umbrella term “XR” but much of the documentation currently still uses the term “VR”. The XR API surface is minimal by design, but will expand as XR continues to grow.
Al utilizar el soporte VR nativo en Unity, usted gana:
To enable native VR support for your game builds and the Editor, open the Player Settings (menu: Edit > Project Settings > Player). Select Other Settings and check the Virtual Reality Supported checkbox. Set this for each build target. Enabling virtual reality support in a standalone build does not also enable the support for Android (and vice-versa).
Use the Virtual Reality SDKs list displayed below the checkbox to add and remove VR devices for each build target. The order of the list is the order that Unity tries to enable VR devices at runtime. The first device that initializes properly is the one enabled. This list order is the same in the built player.
Your built application initializes and enables devices in the same order as the Virtual Reality SDKs list in Other Settings (see Enabling VR Support, above). Devices not present in the list at build time are not available in the final build. Device None is equivalent to a non-VR application (that is, a normal Unity application) and can be switched to during runtime without including it in the list; the exception to this is None.
Including None as a device in the list allows you to default to a non-VR application before attempting a VR device’s initialization. If you place None at the top of the list, the application starts with VR disabled. Then, you can then enable and disable VR devices that are present in your list through script using XR.XRSettings.LoadDeviceByName.
If initialization of the device you attempt to switch to fails, Unity disables VR with that device still set as the active VR device. When you switch devices (XRSettings.LoadDeviceByName) or enable XR (XR.XRSettings-enabled), the built application attempts to initialize again.
The command line argument used to launch a specific device is:
where DEVICETYPE is one of the names from the supported XR supported devices list.
MyGame.exe -vrmode oculus
Cuando VR esté habilitado en Unity, unas pocas cosas suceden automáticamente:
All Cameras in your Scene are able to render directly to the head-mounted display (HMD). View and Projection matrices are automatically adjusted to account for head tracking, positional tracking and field of view.
It is possible to disable rendering to the HMD using the Camera component’s stereoTargetEye property. Alternatively, you can set the Camera to render to a Render Texture using the Target Texture property.
Head tracking and the appropriate field of view (FOV) is automatically applied to the Camera if your device is head-mounted. You can manually set the FOV to a specific value, but you cannot set the Camera’s transform values directly. See the section below on Understanding the Camera to learn more.
El seguimiento de cabeza y el seguimiento de posición se aplican automáticamente, para que la posición y orientación coincida en su mayoría con la posición y orientación del usuario antes de que cada frame sea renderizado. Esto da una experiencia de realidad virtual buena, y evita que el usuario experimente nauseas.
The Camera Transform is overridden with the head-tracked pose. To move or rotate the Camera, attach it as a child of another GameObject. This makes it so that all Transform changes to the parent of the Camera affect the Camera itself. This also applies to moving or rotating the camera using a script.
Think of the Camera’s position and orientation as where the user is looking in their neutral position.
Hay diferencias entre experiencias sentadas y de escala a un cuarto:
Each Camera that is rendering to the device automatically replaces the FOV of the Camera with the FOV that the user input in the software settings for each VR SDK. The user cannot change the field of view during runtime, because this behaviour is known to induce motion sickness.
If your VR device supports Unity Editor mode, press Play in the Editor to test directly on your device.
EL ojo izquierdo es renderizado a la ventana del Game View si usted tiene stereoTargetEye configurado a left or both. El ojo derecho es renderizado si usted tiene stereoTargetEye configurado a right.
There is no automatic side-by-side view of the left and right eyes. To see a side-by-side view in the Game View, create two Cameras, set one to the left and one to the right eye, and set the viewport of display them side by side.
Note that there is overhead to running in the Editor, because Unity IDE needs to render each window, so you may experience lag or judder. To reduce editor rendering overhead, open the Game View and enable Maximize on Play.
The Unity Profiler is a helpful tool to get an idea of what your performance will be like when running outside of the Editor. However, the profiler itself also has overhead. The best way to review game performance is to create a build on your target platform and run it directly. You can see the best performance when running a non-development build, but development builds allow you to connect the Unity profiler for better performance profiling.
Lograr un frame rate similar a su HMD destino es esencial para tener una buena experiencia VR. Este debe coincidir con el refresh rate (tasa de actualización) de la pantalla utilizada en el HMD. Si el frame rate cae debajo del refresh rate del HMD, esto se nota en particular y a menudo lleva a que cause nauseas al jugador.
Refresh rates para dispositivos VR:
|VR Device||Refresh Rate|
Windows: Windows 7, 8, 8.1, y Windows 10 son todos compatibles.
Android: Android OS Lollipop 5.1 o superior.
OS X: OSX 10.9+ con Oculus 0.5.0.1 runtime. Sin embargo, Oculus ha pausado el desarrollo para OS X, entonces utilice Windows para una funcionalidad VR nativa en Unity.
Graphics card drivers: Asegúrese de que sus drivers (controladores) estén actualizados. Cada dispositivo se mantiene al día con los drives más nuevos, por lo que los drivers más viejos podrían no estar soportados.
Each VR device requires that you have appropriate runtime installed on your machine. For example, to develop and run Oculus within Unity, you need to have the Oculus runtime (also known as Oculus Home) installed on your machine. For Vive, you need to have Steam and SteamVR installed.
Depending on what version of Unity you are using, the runtime versions for each specific device that is supported by Unity may differ. You can find runtime versions in the release notes of each major and minor Unity release.
With some version updates, previous runtime versions are no longer supported. This means that native Unity VR support does not work with earlier runtime versions, but continues to work with new runtime versions.
Unity native VR support does not read plug-ins from within your project’s folder, so including earlier versions of the plug-in with native support will fail if you have VR support enabled. If you wish to use an earlier version with a release of Unity that no longer supports that version, disable Native VR Support (go to Other Settings and uncheck Virtual Reality Supported). You can then access the plug-in like any other 3rd party plugin. See the section above on Enabling Unity VR Support for more details.