Plane Detection Sample
This sample demonstrates how to visualize tracked planes found in the real world.
For basic information about plane detection/tracking and what AR Foundation's AR Plane Manager
component does, please refer to the Unity documentation.
In order to use this feature it has to be enabled in the OpenXR plugin settings located under Project Settings > XR Plug-in Management > OpenXR (> Android Tab)
.
How the sample works
First and foremost, make sure to have the Plane Detection
feature enabled in the OpenXR project settings.
There are just two components needed in the scene to see planes when running the experience.
Adding the ARPlaneManager
to the XR Origin gameObject will enable the Plane Subsystem included in the Snapdragon Spaces package. The component provides a field for defining a prefab to spawn upon creating a plane. This prefab has the AR Plane
and AR Plane Mesh Visualizer
attached to it, next to Mesh Renderer
and Line Renderer
. The mesh and the lines are adjusted by the AR Plane Mesh Visualizer
periodically and result in a plane drawn with a fill and border that can be adjusted by altering the materials and properties of the renderers. Furthermore, a Mesh Collider
component can be added to the prefab to receive ray cast hits.
When the sample is running the user can toggle the option to Use Convex Hull. When Use Convex Hull is enabled, the convex hull of the detected planes is used to generate more complex shapes. When disabled, it will generate planes based on the extents of the detected planes instead.
There can be false positives for dynamically moving objects or people. False positives are short-lived because the planes are updated frequently.