Version: 2019.1
Mixed Reality Devices
Dispositivos de VR (Realidad Virtual)

Visión General de VR (Realidad Virtual)

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:

  • Versiones estables de cada dispositivo de VR
  • Una sola interfaz API para interactuar con diferentes dispositivos de VR
  • Una carpeta de proyecto limpia sin ningún plugin externo para cada dispositivo
  • La habilidad de incluir y cambiar entre varios dispositivos en sus aplicaciones
  • Better performance (Lower-level Unity engine optimizations are possible for native devices)

Habilitando el Soporte VR de Unity

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.

Habilitando Virtual Reality Support a través de los ajustes de XR
Habilitando Virtual Reality Support a través de los ajustes de XR

Aplicaciones construidas: Escogiendo un dispositivo de inicio

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

Qué pasa cuando VR está habilitado

Cuando VR esté habilitado en Unity, unas pocas cosas suceden automáticamente:

Renderización automática a una pantalla montada a la cabeza (Head-mounted display)

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.

  • Use the 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.

Input automático de seguimiento de cabeza

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.

Understand the Camera

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.

Childing the Main Camera to a GameObject - in this case, a camera container
Childing the Main Camera to a GameObject - in this case, a camera container

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:

  • Si su dispositivo admite una experiencia a escala de la habitación, la posición de inicio de la cámara es el centro del espacio de juego del usuario.
  • Usando la experiencia sentada, puede restablecer las cámaras a la posición neutral usando XR.InputTracking.Recenter().

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.

Modo del Editor

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.

Recomendaciones de hardware y software para el desarrollo VR en Unity

Hardware

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

Software

  • Windows: Windows 7, 8, 8.1, y Windows 10 son todos compatibles.
  • Android: Android 5.1 (Lollipop) or higher.
  • macOS:
  • Oculus: macOS 10.9+ with the Oculus 0.5.0.1 runtime. However, Oculus have paused development for macOS, so use Windows for native VR functionality in Unity.
  • HTC Vive: macOS 10.13.
  • 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.

Requisitos de tiempo de ejecución del dispositivo

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.


  • Automatic head tracking support removed in 2019.1.

NewIn20191

Mixed Reality Devices
Dispositivos de VR (Realidad Virtual)
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961