Please Select Your Location
Australia
Österreich
België
Canada
Canada - Français
中国
Česká republika
Denmark
Deutschland
France
HongKong
Iceland
Italia
日本
Korea
Latvija
Lietuva
Lëtzebuerg
Malta
المملكة العربية السعودية (Arabic)
Nederland
New Zealand
Norge
Polska
Portugal
Russia
Saudi Arabia
Southeast Asia
España
Suisse
Suomi
Sverige
台灣
Ukraine
United Kingdom
United States
Select your country to buy
België
Česká republika
Denmark
Iceland
Italia
Latvija
Lietuva
Lëtzebuerg
Malta
Nederland
Norge
Polska
Portugal
España
Suisse
Suomi
Sverige

Using Direct Preview For Testing On The Headset With Unity


What will you learn?

You will learn to use DirectPreview to preview and test VR apps while building the apps in the Unity editor.

Note:
In this tutorial we will use Unity 2021.3.9f1 and Vive Focus 3.


What is DirectPreview?

In the development process, repeatedly building APKs in Unity is time-consuming. DirectPreview lets developers skip the build process. Developers can preview in both Unity Editor and their HMD device simultaneously.


Confirm the correct Android adb.exe file is being used by Unity

  1. From menu Edit-> Preferences-> External Tools. Find the Android SDK Tools path and click Copy Path.
DirectPreviewUnity.png

  1. On the Windows taskbar, right-click the Windows icon and select System.
  2. In the Settings window, under Related Settings , click Advanced System Settings.
  3. On the Advanced tab, click Environment Variables.
  4. In the User variables window, confirm that there is a variable for ANDROID_HOME and that the path matches the Android SDK Tools path from Unity. If it doesn’t exist, create the variable and paste the path that was copied from Unity.
DirectPreviewUnity.png

  1. Edit the Path variable and add the ANDROID_HOME variable with platform-tools folder path at the end.
DirectPreviewUnity.png

  1. Restart the machine.


Setup Project

  1. From menu Edit-> Project Settings and Select Package Manager.
  2. Input VIVE Registry
    Name VIVE
    URL https://npm-registry.vive.com
    Scope com.htc.upm
    Note

    All space in “URL” and “Scope(s)” must be trimmed
  3. Apply the change.
DirectPreviewUnity.png

  1. From menu: Window-> Package Manager. Install VIVE Wave XR Plugin and click Accept All on the WaveXRPlayerSettingsConfigDialog.
DirectPreviewUnity.png

DirectPreviewUnity.png


Project Settings

  1. In File-> Build Settings, the target platform needs to be set to Android. Click on Switch Platform.
GettingStartedTutorialImage1

  1. From menu: Edit-> Project Settings-> XR Plug-in Management, switch to Windows, Mac and Linux settings tab and enable WaveXR.
DirectPreviewUnity.png

  1. From menu-> Wave-> DirectPreview-> EnableDirectPreview. DirectPreview is now enabled.
DirectPreviewUnity.png



Create a test scene

  1. Add an XR Rig by right-clicking in the Hierarchy window and choose XR-> Convert Main Camera to XR Rig.
DirectPreviewUnity.png

DirectPreviewUnity.png
  1. Add a cube to the scene to use as a reference point to help determine if the preview is working properly.
DirectPreviewUnity.png



For previewing via USB

  1. Connect the headset to the computer
  2. From menu-> Wave-> DirectPreview-> Control Panel
DirectPreviewUnity.png

  1. In the DirectPreview window, set Connect Type to USB
  2. Click Install Device APK and then click Start Device APK
  3. Click Play in the Unity editor

DirectPreviewUnity.png



For previewing via Wi-Fi

  1. Connect the headset to the computer.
  2. From menu-> Wave-> DirectPreview-> Control Panel
DirectPreviewUnity.png

  1. In the DirectPreview window, set Connect Type to Wi-Fi.
  2. Obtain the headset’s IP address by going to Settings-> General-> About-> Headset Status.
DirectPreviewUnity.png

  1. Confirm the headset is connected to the same Wi-Fi network as the computer and that the headset is reachable by opening up a command prompt and pinging the headset’s IP address.
DirectPreviewUnity.png

  1. Add the headset’s IP address to the Device Wi-Fi IP text box in the DirectPreview window
DirectPreviewUnity.png

  1. Place a checkmark in the Enable preview image box, which is only supported over Wi-Fi
  2. Click Install Device APK and then click Start Device APK
  3. Click Start Streaming Server and you should see a command prompt that will automatically display and close
DirectPreviewUnity.png

  1. If you receive a prompt from Windows Defender Firewall regarding the HTC Remote Render Server , then place a checkmark in all of the boxes and click Allow access.
DirectPreviewUnity.png

  1. Click Play in the Unity editor