Instant Preview

Instant Preview allows you to skip the build process and test your VR app instantly on your device, significantly improving iteration time. Instant Preview consists of an Android app for your Daydream-ready device and a plugin for your Unity or Unreal editor. It supports two modes: Full VR Preview mode and Controller-only mode.

Full VR Preview mode reflects your editor changes onto your Daydream device in VR. The Instant Preview mobile app streams head pose and controller data to your game engine, where the plugin will render the scene in stereo and stream video back to your device. This allows for an instant preview of your app with low enough latency to enable comfortable use over longer sessions.

Controller-only mode allows you to stream only controller data over to the editor. Use this when you are only iterating on your controller interactions in your game engine to save your phone the computational burden of running in full VR preview mode.

Other key features:

  • Customizable streaming settings to optimize for resolution or for latency.
  • Ability to stream over both USB-C and Wi-Fi.
  • Compatible with Unity 5.6 and 2017 / Unreal 4.15.

Getting Started in Unity

Instant Preview comes bundled with the Google VR SDK for Unity.

  1. Ensure your build platform is set to Android.
  2. Import the GoogleVRForUnity_*.unitypackage version 1.100.0 or newer if you haven't already.
  3. Add an instance of the GvrInstantPreviewMain prefab from the GoogleVR/Prefabs/InstantPreview folder to your scene hierarchy. The game object persists across scene transitions, so you can add it to your entry point scene root.
  4. Configure Instant Preview as required:

    • Output Resolution: Changes streaming resolution to Big (2560x1440), Regular (1920x1080), or WindowSized (scales with Game Window size).
    • Multisample Count: Adds Multisample Anti-Aliasing to the scene. A value of 1 has no anti-aliasing, while higher values correspond to higher quality.
    • Bit Rate: Encoding bitrate. Lower values encode at lower quality but runs at higher framerate.
    • Install Apk on Run: Ensures you're running the correct version of the Instant Preview Android app on your phone and installs the correct version bundled with the unitypackage if it isn't. This requires that your phone be connected to adb/ via USB.
    • Install the Instant Preview Android app onto your phone. For your convenience, the APK is packaged with the Unity plugin and can be automatically installed from the editor the first time you use it. Enable the Install Apk on Run setting in the Instant Preview script shown above in 4), connect your phone via USB, and click Play in the editor. This should auto-install the app. You can also install it from the command line:

      adb install -r Assets/Scripts/InstantPreview/InstantPreview.apk

  5. Press “Play” in the Unity editor with the Instant Preview prefab enabled to begin previewing your app. The first time you do this while connected to USB, the app will default to previewing via USB. To connect via Wi-Fi, see Switching Connection Types below.

Using the Instant Preview app in Unity

Once you launch the Instant Preview Android app, you will be able to select between USB and Wi-Fi as connection types and Full VR preview and Controller only streaming modes. Pressing Play in the Unity editor will begin the stream.

Choosing a connection type

Streaming over USB is best if you are anticipating a long development session and need the phone to be constantly charging. Wi-Fi is good for shorter-session testing that requires untethered, free range of movement.

To connect via Wi-Fi, Instant Preview uses multicast address 239.170.165.207 on port 49838 to find host computers, so your network must allow this.

If your computer is running the Unity editor with Instant Preview, it should be discoverable by an Instant Preview app running on a phone connected to on the same Wi-Fi network. Tap the drop down field under “Preview via…” to see available computers to stream from.

Tap on a computer name to connect to it. Instant Preview should operate the same way as if you were connected via USB.

Switching connection types

If you’re in VR mode and want to switch between USB or Wi-Fi, you must first return back to 2D mode in the Android app.

  1. Pause the stream in the editor
  2. Press the X button or system back button on your phone. If you’re still currently streaming from the editor, you will see a message asking you to pause the stream.

Unity Streaming Performance Tips

To improve streaming latency, consider disabling vsync on your editor. The option is under Edit > Project Settings > Quality:

Improving performance on OSX

If you are using a Mac, we recommend using Metal to render instead of OpenGL, which is much faster. It can be set under Player Settings > Settings for PC, Mac & Linux Standalone > Other Settings > Metal Editor Support.

On OSX, performance is very sensitive to the size of your preview window. It’s highly advised to check Low Resolution Aspect Ratios on the preview window, and also to keep the preview window to a reasonably small size.

Troubleshooting in Unity

If you are having trouble connecting, please ensure your device is connected to your computer via USB and that you have followed the steps above for your particular engine.

If you cannot connect in Unity, please check the following:

  • Your device is unlocked, and developer options have been enabled.
  • Check for any Instant Preview errors in the Unity Console.
  • If the controller is not working, ensure that the Instant Preview plugin was imported after the GVR Unity plugin.
    • Instant Preview works by overwriting some files in the Google VR SDK for Unity. EmulatorControllerProvider.cs should have a reference to the InstantPreviewControllerProvider inside it if it is setup correctly.
  • Your build platform is set to Android.
  • You have added the GvrInstantPreviewMain prefab to your scene.
  • Confirm that when you press Play in Unity, the Console displays both 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, please report it at the Google VR SDK for Unity issues page.

Getting started in Unreal

To use Instant Preview in Unreal, you need both the Android app and the corresponding plugin for Unreal. The Android App is included with the Google VR Unreal branch.

  1. Create and set up a Google VR Unreal project.
  2. Install the Instant Preview app:

    adb install -r UnrealGithub/Engine/Source/ThirdParty/GoogleInstantPreview/InstantPreview.apk

  3. Launch Instant Preview. Ensure that your phone is connected via USB.

  4. Launch the Unreal Editor and open your Google VR enabled project. The Instant Preview app should tell you that it is ready to stream.
  5. Start your project in the editor in VR Preview mode.

  6. To change the resolution, select advanced settings in the Play dropdown menu, and change the play-in-editor window resolution to the desired setting.

Using the Instant Preview app

When you launch the app, you will be able to select between Full VR preview and Controller only streaming modes.

  • Pressing PLAY in your Unity or Unreal editor will begin the stream.
  • To switch preview modes, you must first press PAUSE in your editor.

Troubleshooting in Unreal

If you are having trouble connecting, please ensure your device is connected to your computer via USB and that you have followed the steps above for your particular engine.

If you cannot connect in Unreal, please check the following:

  • You have set the ANDROID_HOME environmental variable to point at the Android SDK Path (e.g. %LocalAppData%\Android\sdk\)
  • You have enabled the Google VR Plugin in your project.
  • Check that the .dll and .dylib files under:

    Engine\Binaries\ThirdParty\GoogleInstantPreview\<your_platform>\Release\

    are the same as those in:

    Engine\Source\ThirdParty\GoogleInstantPreview\<your_platform>\Release\

If your issue is not addressed here, please report it at our Instant Preview issues page on GitHub.