
Augmented Reality with Unity AR Foundation
By :

Before moving on and building an AR project, it is prudent to verify your project has been set up properly so far by trying to build and run it on your target device. For this, we'll create a minimal AR scene and verify that it satisfies the following checklist:
I'll walk you through this step by step. Don't worry if you don't understand everything; we will go through this in more detail together in Chapter 2, Your First AR Scene. Please do the following in your current project, which should be open in Unity:
Scenes
folder, call it BasicTest
, and click Save.ar point
in the search field and select AR Point Cloud Manager.You will notice that the Point Cloud Manager has an empty slot for a Point Cloud Prefab, which is used for visualizing the detected depth points. A prefab is a GameObject saved as a project asset that can be added to the scene (instantiated) at runtime. We'll create a prefab using a very simple Particle System. Again, if this is new to you, don't worry about it – just follow along:
PointParticle
.0.1
.ar point
in the search field, and select AR Point Cloud.The Inspector window of the PointParticle object should now look as follows:
Figure 1.16 – Inspector view of our PointParticle prefab with the settings we're using highlighted
We can now apply the PointParticle prefab to the AR Point Cloud Manager, as follows:
The resulting AR Session Origin should look as follows:
Figure 1.17 – Session Origin with a Point Cloud Manager component populated with the PointParticle prefab
Now, we are ready to build and run the scene. Perform the following steps:
Builds/
. Give it a filename (if required) and press Save. It may take a while to complete this task.If all goes well, the project will build, install on your device, and launch. You should see a camera video feed on your device's screen. Move the phone slowly in different directions. As it scans the environment, feature points will be detected and rendered on the screen. The following screen capture shows my office door with a point cloud rendered on my phone. As you scan, the particles in the environment that are closer to the camera appear larger than the ones further away, contributing to the user's perception of depth in the scene.
Figure 1.18 – Point cloud rendered on my phone using the BasicTest scene
If you encounter errors while building the project, look at the Console window in the Unity Editor for messages (in the default layout, it's a tab behind the Project window). Read the messages carefully, generally starting from the top. If that doesn't help, then review each of the steps detailed in this chapter. If the fix is still not apparent, do an internet search for the message's text, as you can be certain you're probably not the first person to have a similar question!
Tip – Build Early and Build Often
It is important to get builds working as soon as possible in a project. If not now, then certainly do so before the end of the next chapter, as it does not make a lot of sense to be developing an AR application without having the confidence to build, run, and test it on a physical device.
With a successful build, you're now ready to build your own AR projects. Congratulations!