Develop
Develop
Select your platform

Unity Plane and Volume Scene Sample (deprecated)

OVRSceneManager Deprecation
As of v65, OVRSceneManager is deprecated. New features will be delivered through MR Utility Kit.
Refer to the following as guidance on which APIs to use:
New projects:
Existing projects:

Introduction

This sample visualizes an existing Scene Capture using simple prefabs.

Prerequisites

Before you can build this sample, review the requirements in the Scene Samples Overview.

Step by Step

  1. Download the Starter Samples project from Github and integrate the samples into your project following the Starter Samples instructions.
  2. In the Unity Project explorer, search for the SceneManager scene. You can find it in Unity in Assets > StarterSamples > Usage. Drag it to your Hierarchy window.
  3. Remove any other scene from the Hiearchy Window.
  4. Save your project and your scene.
  5. From the File menu, choose Build Settings to open the Build Settings window.
  6. Make sure your Meta Quest headset is the selected device in the Run Device dropdown. If you don’t see your headset in the list, click Refresh.
  7. Click Add Open Scenes to add your scene to the build. Deselect and remove any other scenes from the selction window.
  8. Click the Build and Run button to launch the program onto your headset.

Using the Sample

As Space Setup can only be run on-device, it is advised to have run this before working with the samples.
When you enter the sample scene, you will see anchors distributed around your room, marking the placement of the walls and objects that you have defined within your boundary. Depending on the object, the anchors are instantiated using a plane or a volume prefab.
Each prefab contains a gizmo showing the orientation of the three axes:
  • Red: X axis
  • Green: Y axis
  • Blue: Z axis
When instantiated, the prefab is placed and then scaled to match the dimensions of the plane or volume it is meant to represent, such as a wall or a table.
Instantiated and scaled prefab

Key Assets

OVRSceneManager Game Object | .\Assets\Oculus\VR\Prefabs | Encapsulates Scene behavior.
OVRSceneModelLoader.cs Script | .\Assets\Oculus\VR\Scripts | Load the stored Scene Model. If no model exists, it will try to run Space Setup once to define the model.
OVRSceneManager.cs Script | .\Assets\Oculus\VR\Scripts | This script is attached to the OVRScreneManager game object. At runtime the script queries the Scene Model and instatiates planes and volumes based on the saved features of the model.
PlaneMesh Prefab | .\Assets\StarterSamples\Usage\SceneManager\Prefabs | Used by the OVRSceneManager.cs script to attach planes to walls, ceilings, and floors. Any Scene object which has both 2D and 3D components (such as table and couch) is handled by the Volume Prefab.
Volume Prefab | .\Assets\StarterSamples\Usage\SceneManager\Prefabs | Used by the OVRSceneManager.cs script to attach to three dimensional objects in the scene, such as lamps, beds, and plants (a complete list of labels can be found in Use the Scene Model).
OVRSceneAnchor.cs Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts | Used by the PlaneMesh and Volume prefabs. This script initializes and manages the anchors placed on planes and volumes.
VolumeAndPlaneSwitcher.cs Script | Used by the PlaneMesh prefab to correctly align planes with 2D surfaces and Volumes with 3D objects.
OVRScenePlaneMeshFilter.cs Script | A component of the PlaneMesh prefab. Used to generate a mesh that represents a plane’s boundary, most commonly for representing the wall polygon on the floor anchor.