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 provides forward compatibility for future devices and software.
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 XR Settings and check the Virtual Reality Supported checkbox. Set this for each build target. Enabling virtual reality support in a standalone build doesn’t also enable the support for Android (and vice-versa).
Use the Virtual Reality SDKs list below the checkbox to add and remove VR devices for each build target. The order of the list is the order in which 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 XR Settings (see Enabling VR Support, above). Devices not present in the list at build time are not available in the final build; the exception to this is None. 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.
If you include None as a device in the list, the application can default to a non-VR application before it attempts to initialize a VR device. 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.
Si la inicialización del dispositivo al que intenta cambiar falla, Unity deshabilita VR con ese dispositivo aún configurado como el dispositivo VR activo. Cuando cambia dispositivos (XRSettings.LoadDeviceByName) o habilita XR (XR.XRSettings-enabled), la aplicación construida intenta inicializarse. otra vez.
Use the following command line argument to launch a specific device:
-vrmode DEVICETYPE
donde DEVICETYPE es uno de los nombres de la lista de dispositivos compatibles con XR.
Ejemplo: MyGame.exe -vrmode oculus
Cuando VR esté habilitado en Unity, unas pocas cosas suceden automáticamente:
All Cameras in your Scene can render directly to the head-mounted display (HMD). Unity automatically adjusts View and Projection matrices to account for head tracking, positional tracking and field of view.
Es posible deshabilitar la renderización en el HMD utilizando la propiedad stereoTargetEye del componente de la cámara. Alternativamente, puede configurar la Cámara para que se renderice en una Render Texture utilizando la propiedad Target Texture.
stereoTargetEye
property to set the Camera to only render a specific eye to the HMD. This is useful for special effects such as a sniper scope or stereoscopic videos. To achieve this, add two Cameras to the Scene: one targeting the left eye, the other targeting the right eye. Set layer masks to configure what Unity sends to each eye.Unity versions newer than 2019.1 no longer support automatic head tracking for head-mounted devices. Use the Tracked Pose Driver feature of the XR Legacy Input Helpers package to implement this functionality.
You can install the XR Legacy Input Helpers package using the Package Manager window.
Unity overrides The Camera Transform with the head-tracked pose. To move or rotate the Camera, attach it as a child GameObject 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.
Piense en la posición y orientación de la cámara como donde el usuario está mirando en su posición neutral.
Hay diferencias entre experiencias sentadas y de escala a un cuarto:
Cada cámara que se está rindiendo al dispositivo reemplaza automáticamente el FOV de la cámara con el FOV que el usuario ingresa en la configuración del software para cada VR SDK. El usuario no puede cambiar el campo de visión durante el tiempo de ejecución, porque se sabe que este comportamiento induce el mareo por movimiento.
Si su dispositivo VR admite el modo Editor de Unity, presione Reproducir en el Editor para probar directamente en su dispositivo.
The left eye renders to the Game View window if you have stereoTargetEye set to left or both. The right eye renders if you have stereoTargetEye set to right.
No hay una vista automática de lado a lado de los ojos derecho e izquierdo. Para ver una vista de lado a lado en la Vista del juego, cree dos Cámaras, coloque una a la izquierda y otra al ojo derecho, y configure la ventana de visualización de forma que se muestren una al lado de la otra.
Note that there is overhead to running in the Editor, because Unity IDE needs to render each window, so you might 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 should be like when it runs 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 you run 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.
La siguiente tabla enumera las tasas de actualización de dispositivos para auriculares VR comunes:
VR Device | Refresh Rate |
---|---|
Gear VR | 60hz |
Oculus Rift | 90hz |
Vive | 90hz |
Cada dispositivo VR requiere que tenga instalado el tiempo de ejecución adecuado en su máquina. Por ejemplo, para desarrollar y ejecutar Oculus en Unity, necesita tener instalado el tiempo de ejecución de Oculus (también conocido como Oculus Home) en su máquina. Para Vive, necesitas tener Steam y SteamVR instalados.
Depending on what version of Unity you are using, the runtime versions for each specific device that Unity supports may differ. You can find runtime versions in the release notes of each major and minor Unity release.
Con algunas actualizaciones de versión, las versiones anteriores en tiempo de ejecución ya no son compatibles. Esto significa que el soporte nativo de Unity VR no funciona con versiones anteriores en tiempo de ejecución, pero continúa trabajando con nuevas versiones en tiempo de ejecución.
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 fails 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 XR 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.
NewIn20191