DirectPreview

Introduction

In the development process, building APKs repeatedly in Unity is time-consuming. Direct Preview lets developers skip the build process by letting developers preview in both the Unity Editor and their headset simultaneously.

Note

The rendering path for Android applications differs from the rendering path used for game previews. Therefore, there may be differences in the look-and-feel and performance.

Architecture

../_images/1_arch.png

Direct Preview is separated into three parts:

  1. wvr_plugins_directpreview_agent_unity.apk on your target device

There are 2 major tasks in wvr_plugins_directpreview_agent_unity.apk:

  • wvr_plugins_directpreview_agent_unity.apk gets all data such as pose, event and state of the headset/controllers and sends them to wvr_plugins_directpreview.dll through USB/Wi-Fi.
  • wvr_plugins_directpreview_agent_unity.apk also takes over the images sent from dpServer, decodes the images, and displays the images on your target device.
  1. wvr_plugins_directpreview.dll on your Unity Editor

Unity Editor will load wvr_plugins_directpreview.dll when you start playing. After initialization and connection, it provides all data (pose, event and state of device) from wvr_plugins_directpreview_agent_unity.apk on your target device to Unity which operates all routines and draws images on texture.

After drawing texture is completed, wvr_plugins_directpreview.dll will send texture images from Unity with corresponding pose data to dpServer.

  1. dpServer on PC
dpServer takes over the Unity textures and the poses sent from wvr_plugins_directpreview.dll. And then, dpServer encodes these information and sends them to the target device.

System Requirements

  • Microsoft® Windows® only.
  • Microsoft DirectX® 11 is needed.
  • Minimum graphics card: NVIDIA® GeForce® GTX 980. NVIDIA® GeForce® GTX 1080 is recommended for dpServer for better performance. It is also recommended to update the graphics card driver to the latest version.

Note

  • To successfully execute adb.exe, make sure the Path System Environmental Variable for Android SDK platform tools has been set.
  • To use Direct Preview, make sure the proximity sensor (P-sensor) on the headset is covered/blocked to keep it awake.
../_images/notice.png

How to Use

  1. In XR Plug-in Management, select WaveXR in PC tab. To use direct preview, make sure the WaveXR plugin is enabled.
../_images/wavexrdp.png
  1. In the Unity Editor, click Wave > DirectPreview, and then select EnableDirectPreview
../_images/DP.JPG
  1. Click Wave > DirectPreview, and then select ControlPanel.
../_images/Panel.JPG
  1. Set the Connect Type

There are 2 types of connection: USB and Wi-Fi .

../_images/usb.JPG

USB

Get device information (pose, event, state) through USB. Play mode images can be seen in Unity Editor only, but not in the headset.

Step 1. In DirectPreview ControlPanel, select Install Device APK. DirectPreview will automatically install the APK to the headset and create a “config.json” in the path “/sdcard/DirectPreview” in the headset.

../_images/usb_installapk.JPG

Note

Make sure there’s no white-space in your project path or else the apk installation process may fail. You can check your installation path in Unity console window.

../_images/notice_path.png

Step 2. In DirectPreview ControlPanel, select Start Device APK. This starts wvr_plugins_directpreview_agent_unity.apk on your headset.

../_images/usb_startapk.JPG

Start wvr_plugins_directpreview_agent_unity.apk on your headset.

Note

  • Make sure the proximity sensor on the headset is covered/blocked to keep the headset awake.

Step 3. After the connection is made, click the Play button in the Unity Editor to preview instantly.

../_images/s7.png

Note

Before closing the Unity Editor, make sure Play mode is turned off in Unity.

Step 4. In DirectPreview ControlPanel, select Stop Device APK to stop running the APK in the headset.

../_images/usb_stopapk.JPG

Wi-Fi

Select to connect Unity and the headset with Wi-Fi. When using Wi-Fi, you can get device information from the headset and also stream the Play mode images to it.

../_images/wifi.JPG
  • Device Wi-Fi IP
Enter the Wi-Fi IP address here.
  • Enable preview image

    • Select to present the corresponding effect according to the pose, event and state returned from the headset, and to show the Unity playing mode images in both Unity playing mode and the headset.
    • Disable if you only want to present the corresponding effect in the Unity playing mode only.
  • Update frequency

    Set the number of images that will be sent to the headset per second based on different network conditions.

    If Runtime defined is selected, it will set the value automatically according to the defined value in the headset. If the defined value doesn’t exist, or the defined value is abnormal, it will set the value to 75 FPS.

Note

FPS here means how many images Unity Editor will send to the APK via the dpServer, instead of the FPS shown in Unity Editor.

  • Render target device

Select the target device.

Note

  • Selecting a target device that does not match the actual target device will cause abnormal streaming behavior.
  • You need to reinstall the Device APK if you change the Render target device.
  • Preview image ratio
Choose the image size shown in the headset.
  • Regularly save images
Select to regularly get two-eye images from Unity, and save them (dp_unity_imageXX_number.jpg and dp_unity_imageXX_number.jpg ) in D:/ .

Step 1. In DirectPreview ControlPanel, select Install Device APK. DirectPreview will automatically install the APK to the headset and create a “config.json” in the path “/sdcard/DirectPreview” in the headset.

../_images/wifi_installapk.JPG

Note

Make sure there’s no white-space in your project path or else the apk installation process may fail. You can check your installation path in Unity console window.

../_images/notice_path.png

Step 2. In DirectPreview ControlPanel, and then select Start Streaming Server.

../_images/wifi_startserver.JPG
../_images/step5.png

Command line window you will see after selecting Start Streaming Server

Note

  • You can manually start dpServer.exe in “Packages/com.htc.upm.wave.xrsdk/Runtime/DirectPreview/Binary/” if dpServer doesn’t start automatically.

Step 3. In DirectPreview ControlPanel, select Start Device APK. This starts wvr_plugins_directpreview_agent_unity.apk on your headset.

../_images/wifi_startapk.JPG

Start wvr_plugins_directpreview_agent_unity.apk on your headset.

Note

  • Make sure the proximity sensor on the headset is covered/blocked to keep the headset awake.
  • Make sure device apk and dpServer are connected if Wi-Fi mode is selected.
../_images/connected.png

Step 4. After the connection is made, click the Play button in the Unity Editor to preview instantly.

../_images/s7.png

Note

Before closing the Unity Editor, make sure Play mode is turned off in Unity.

Step 5. In DirectPreview ControlPanel, select Stop Device APK to stop running the APK in the headset.

../_images/wifi_stopapk.JPG

Step 6. In DirectPreview ControlPanel, select Stop Streaming Server to stop the dpServer.

../_images/wifi_stopserver.JPG

FAQs

  1. I can’t connect to the steaming server with the device apk, what should I do?
  1. In DirectPreview ControlPanel, select Start Device APK again.
  2. Make sure your headset and PC are connected to the same domain. In DirectPreview ControlPanel, check that the IP address in Device Wi-Fi IP is the same as the IP address your headset is connected to.
  3. If you change your headset and PC to another Wi-Fi domain after installing the device apk, re-install the device apk to initialize the config file with the new Wi-Fi domain information.
  1. I can’t see the Unity editor preview display on the headset. Also, the device model (camera and controller) in the game/scene window of the Unity Editor does not match the pose from the headset. What should I do?

    1. Stop the preview.
    2. Close the streaming server and Device app.
    3. Restart the streaming server.
    4. Restart the Device app.
    5. After rrServer is connected with wvr_plugins_directpreview_agent.apk, click on the Play button in Unity Editor.
  2. Streaming is not smooth and/or the resolution is not what I expected, what can I do?

This usually happens when you’re not in a fast and stable network or the bandwidth is not enough to stream with good quality. Try the following:

  1. Lower the Update frequency value.
  2. Lower the Preview image ratio value or adjust the game viewport.