Next, we need an AR camera. We can use the default Main Camera already in the scene, but it must be parented by ARRoot.
- Select Main Camera from the Hierarchy and drag it to make it a child of ARRoot.
- Reset the Main Camera's position to (0, 0, 0) if necessary (Transform gear-icon | Reset).
- We want this camera only to be working with objects in Root. Therefore, set its Culling Mask to AR Background 2 so that it matches the layer that Root is in (select Culling Mask | Nothing, then Culling Mast | AR Background 2).
- Then, use Add Component to add the AR Camera component to the camera.
The Hierarchy should now look like this:
At this point we can test it. When you press Play (the play-icon on the toolbar at the top-center of Unity), you should see the feed from your web camera in the Game panel. This allows you to debug the AR application within the Unity editor.
You can exert a great deal of control over the physical camera options via this component. Using C# scripts you can write. You can also use the separate calib_camera camera calibration utility included with the ARToolkit tools. See more at https://archive.artoolkit.org/documentation/doku.php?id=2_Configuration:config_camera_calibration.
If you encounter an error like DllNotFoundException: [...]/Assets/Plugins/ARWrapper.dll locate the DLL file(s) in the projects Assets/Plugins/x86_64 path (if running 64 bit Unity on Windows, for instance), and make sure that Editor is one of the Include Platforms specified. We have heard of cases where developers never got it to work when using Play from the Unity Editor, but could still successfully build and run to their Android device just the same.