Detecting and highlighting planes with AR Foundation
One of the features of AR is its ability to detect flat surfaces through device cameras and other sensors (such as the LIDAR sensors on some high-end iPads and iPhones).
This recipe illustrates how a Unity AR Raycast, combined with some AR Foundation objects and scripts, can work to highlight detected planes (both horizontal and vertical) with a circular highlight:
Figure 17.18: A plane being detected in an indoor scene
Getting ready
This recipe follows the previous one, so make a copy of it and work on that copy.
We also need an image to display on the detected planes. We have provided a suitable circular image called plane_highligher.png
in the 17_04
folder.
How to do it...
To create an AR plane highlighter app, do the following:
- Delete the two cubes in the Hierarchy panel.
- In the Hierarchy panel, select the
XR Origin
GameObject. In the Inspector panel, add an AR Plane Manager...