Instant Preview

Use Instant Preview to test VR apps that you are building in Unity instantly on your phone. Instant Preview lets you skip the build process and improve iteration time.

Overview

Instant Preview consists of an Android app for your Daydream-ready phone and a plugin for Unity or Unreal Engine.

In Instant Preview, you can:

  • Preview your app's full VR experience in the editor or use just the physical Daydream controller in the editor
  • Use USB or Wi-Fi streaming
  • Configure streaming to optimize for resolution or for latency

Developer considerations

  • Rendering happens on your development machine, meaning that Instant Preview is not suitable for performance testing or for calling Android APIs directly.

  • When streaming over Wi-Fi, use Instant Preview while on a secure network with a firewall enabled. Communication between your development machine and your phone uses unencrypted TCP over an open port.

Get started

This guide assumes that you have already created a Google VR project in Unity. If you are new to working with the Google VR SDK, see the Unity Quickstart guide.

  1. In the Unity Project window, navigate to GoogleVR > Prefabs > InstantPreview.

  2. Add an instance of the GvrInstantPreviewMain prefab from the InstantPreview folder to your scene hierarchy. The game object persists across scene transitions, so you can add it to the root of your loading scene.

    By default, the GvrInstantPreviewMain prefab is configured to install the Instant Preview Android app automatically when you run your app in the Unity Editor.

    You can also install the app from the command line:

    adb install -r Assets/GoogleVR/Scripts/InstantPreview/InstantPreview.apk
    
  3. Make sure that your phone is connected to your computer via USB and click Play in the Unity Editor to start previewing your app.

  4. After launching the Instant Preview app, click Pause in the Unity Editor to stop streaming. Tap the X button or system back button on your phone to exit VR mode.

  5. (Optional) You can make additional configurations while your app is paused and your phone is not in VR Mode. See the following sections for details on:

Switch preview modes

In Instant Preview, you can opt to stream your app's full VR experience or controller interactions only.

Mode Description Use for
Full VR preview
  • Changes you make in the editor are visible immediately on your phone in VR.
  • Instant Preview streams head pose and controller data to your development machine, where the game engine renders the scene in stereo and streams video back to your phone.
  • Provides an instant preview of your app with low enough latency to make longer usage sessions comfortable
Longer usage sessions iterating on multiple aspects of your app.
Controller only
  • Streams only controller data to the editor.
  • No stereo preview shown on the phone.
Iterating only on controller interactions

To switch preview modes:

  1. If your app is currently running, click Pause in the Unity Editor.
  2. Tap the X button or system back button on your phone to exit VR mode.
  3. In the Instant Preview app on your phone, use the Preview via... dropdown to select Full VR preview or Controller only mode.
  4. Click Play in the Unity Editor to begin streaming.

Stream over a Wi-Fi connection

Instant Preview works the same way when streaming over USB or Wi-Fi.

By default, Instant Preview uses USB. Streaming over USB is best for long development sessions.

Use Wi-Fi for shorter testing sessions that require an untethered range of movement.

To stream over Wi-Fi:

  1. Instant Preview uses multicast address 239.170.165.207 on port 49838 to find host computers. Make sure that your network allows this connection.
  2. Connect to your computer:

    • If your app is currently running, click Pause in the Unity Editor.
    • Tap the X button or system back button on your phone to exit VR mode.
    • If your computer is running the Unity editor with Instant Preview, it should be discoverable from the Instant Preview app running on a phone connected to the same Wi-Fi network.
    • In the Instant Preview app on your phone, tap the drop-down field under Preview via… to see available computers.
    • Tap a computer name to connect to it.
  3. Click Play in the Unity Editor to begin streaming.

Configure prefab settings

In the Unity Editor, you can configure the following GvrInstantPreviewMain prefab settings:

Setting Description
Output resolution
  • Big (default): 2560 x 1440
  • Regular: 1920 x 1080
  • WindowSized: scales with Game Window size
Multisample Count
  • Adds Multisample Anti-Aliasing (MSAA) to the scene
  • Defaults to One, meaning no anti-aliasing
  • Higher values correspond to higher quality
Bit Rate
  • Encoding bitrate
  • Defaults to 16000
  • Lower values encode at lower quality but run at a higher framerate
Install Apk on Run
  • Ensures that the correct version of the Instant Preview Android app is installed and running on your phone each time you click Play in the editor
  • Defaults to Enabled
  • Requires your phone to be connected to adb via USB

Performance tips

To improve streaming latency, consider disabling Vsync in the editor.
You can disable Vsync from Edit > Project Settings > Quality:

If you are working in macOS, try the following adjustments:

  • Use Metal for rendering instead of OpenGL.
    Go to Player Settings > Settings for PC, Mac & Linux Standalone > Other Settings > Metal Editor Support to enable Metal rendering.
  • As performance is affected by the size of your preview window:
    • Select Low Resolution Aspect Ratios on the preview window.
    • Keep the preview window to a reasonably small size.

Troubleshooting

If you run into issues, check for any Instant Preview errors in the Unity Console.

Additionally, make sure that:

  • Your phone is connected to your computer via USB

  • Your phone is unlocked and developer options are enabled

  • In Unity's Build Settings, your build platform is set to Android

  • You completed the Instant Preview setup steps in this guide.

  • The GvrInstantPreviewMain prefab exists and is enabled in your scene

  • When you press Play in Unity, the Console displays both Google VR SDK for Unity Version: 1.xx and Instant Preview Version: 1.0.0.x (where x is replaced by a version number)

If your issue is not addressed here, you can report it on the Google VR SDK for Unity issues page.