- Augmented Reality for Developers
- Jonathan Linowes Krystian Babilinski
- 214字
- 2025-04-04 18:11:44
Adding AR Camera prefab to the Scene
The first step is to replace the default Main Camera with Vuforia's AR Camera prefab:
- In the Hierarchy panel, delete the Main Camera (select it and press the Delete key or right-click Delete).
- In the Project panel in the Assets/Vuforia folder, there's a Prefabs/ folder-click on that.
- Select the prefab named AR Camera and drag it into the Hierarchy list.
When you press Play (the play icon on the toolbar at the top-center of Unity), you should see the feed from your selected web camera in the Game panel. This allows us to debug the AR application within the Unity Editor.
If you do not see the video feed, double check that the VuforiaConfiguration's Webcam Camera Device is set to your webcam, and/or that the camera is working properly (in Windows, it can be found in Device Manager | Imaging Devices).
We also want add the CameraSettings component to the camera. For some reason, the Vuforia AR Camera prefab does not use autofocus by default. For some platforms, such as Android, this is really needed:
- Select AR Camera in Hierarchy
- In Inspector choose Add Component and search for Camera Settings (or navigate to Scripts | Camera Settings)
- Select the component to add it to the camera object.