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.
In the Unity Project window, navigate to GoogleVR > Prefabs > InstantPreview.
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
Make sure that your phone is connected to your computer via USB and click Play in the Unity Editor to start previewing your app.
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.
(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:
- Switching preview modes
- How to stream over Wi-Fi instead of USB
- Customizing GvrInstantPreviewMain prefab settings
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 |
|
Longer usage sessions iterating on multiple aspects of your app. |
Controller only |
|
Iterating only on controller interactions |
To switch preview modes:
- 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.
- In the Instant Preview app on your phone, use the Preview via... dropdown to select Full VR preview or Controller only mode.
- 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:
- Instant Preview uses multicast address 239.170.165.207 on port 49838 to find host computers. Make sure that your network allows this connection.
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.
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 |
|
Multisample Count |
|
Bit Rate |
|
Install Apk on Run |
|
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.
- Select Low Resolution Aspect Ratios on the preview window.
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 sceneWhen 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.