Passthrough Overlay Sample
This sample demonstrates how to modify the foreground characteristics of the passthrough layer with respect to any virtual objects that are present.
Before proceeding with this tutorial, complete the setup steps outlined in
Passthrough Getting Started to set up your Unity development environment for Passthrough.
- If you prefer, set up the Meta Quest Developer Hub so that you can control your on-headset application.
- In the Unity Project explorer, search for the OverlayPassthrough scene. Drag it to your Hierarchy window.
- Remove any other scene from the Hierarchy Window.
- Save your project and your scene.
- From the File menu, choose Build Settings to open its window.
- Choose your headset in the Run Device dropdown list.
- Click Add Open Scenes to add your scene to the build. Deselect and remove any other scenes from the selection window.
- Click Build and Run to launch the program on your headset.
When you first enter the scene, you see several 3D objects, which display behind the passthrough scene.
Adjust the opacity of the Passthrough layer using the right controller thumbstick. Move the thumbstick left for more transparency, right for more opacity, or leave it in the middle for 50% opacity to reveal the Unity scene beneath it.
There are two ways to adjust the opacity of the Passthrough layer.
You can set the
OVRPassthroughLayer to “Overlay”. This technique is demonstrated in this sample. To view the property, select the
OVRCameraRig object in the Hierarchy window. Then, in the Inspector, expand the
OVR PassthroughLayer (Script).
Alternatively, you can set the opacity to 0, and turn on edge rendering. This gives the Sobel edge-filtered version of Passthrough, rendering above Unity. This technique is not covered in this sample. Find both Opacity and Edge Rendering in OVR PassthroughLayer (Script) as well.
The assets used in this scene are:
InfoPanel.prefab
Provides the scene runtime information.
Location: .\Assets\StarterSamples\Usage\Passthrough\Prefabs
OverlayPassthrough.cs
Provides the overlay opacity control code.
Location .\Assets\StarterSamples\Usage\Passthrough\Scripts