Vuforia is one of the best tools to build augmented reality for mobile devices. Yes, even for both iOS and Android. To enable developer mode and setup, you’ll want to follow these instructions. But why choose to develop in Vuforia instead of ARKit or ARCore? It’s powerful, flexible and built right into Unity’s latest release. But the main benefit of Vuforia is that it allows you to develop for all platforms, and it works on both phones running older versions and all the newest gear. So let’s get Vuforia setup with Unity so you can start building.
To build the app on your phone, you’ll want to follow these steps for mobile app development in our post on building with Unity. Remember to select Android or iOS development, and to deselect Android TV compatibility if building for Android phones.
If you’re already comfortable developing with Vuforia, but you’re looking for help building an AR experience with custom images, check out How to Track Your Own Images in Vuforia. If not, and you’re looking for a guide to get started with Vuforia, this article is for you.
|Download our 10-week AR Development with Unity Course Syllabus|
Download Vuforia into Unity
Assuming you haven’t yet opened Vuforia in Unity, the first step is to download and run the Unity download assistant from the Unity website. When the window of components options pops up, make sure “Vuforia Augmented Reality Support” is selected.
You’ll also want to select your mobile device in the installation process so you can test the AR app you build.
Set Up in Unity
Now that you’ve got all the tools you need, continue your Android-ready Unity project. If you’re building for iOS, you’ll need to create a new project.
Click the GameObject dropdown menu, hover over “Vuforia” and select “AR Camera.” This will build a whole camera rig right into your scene.
Now that we have a camera rig built in, there’s no need for the default Main Camera. In the Hierarchy tab (top left of the main window), delete the Main Camera altogether. Just get it out of there.
To adjust your player settings, you’ll need to click on “Build Settings” in the top File menu. A prompt will appear, and you”ll want to choose “Player Settings” at the bottom.
Now that the inspector shows the player settings, we’ll need to make sure it’s ready to support Vuforia. Scroll down to XR settings, and expand it. Find “Vuforia Augmented Reality Supported” and select it.
Get Vuforia Development Key
Let’s take a break from Unity for a minute and head over to the Vuforia Developer Portal website. If you don’t already have an account, set one up. (It’s free!) Then log in.
Choose the Develop tab at the top, then make sure you’re on the License Manager page and click “Get Development Key.” Make up a name for your app. (Like the site says, you can always change it later!) Read through the licensing regulations, and if you agree, Vuforia will generate your key.
After you open your key, copy the text in the gray box. Then head back into Unity.
In Unity, search “Vuforia Configuration” in the search bar above your Assets tab. Click on “VuforiaConfiguration” when it appears in the Assets tab, and paste your license key into the “App License Key” field, but do not click “Add License.”
Add An Image Target
Vuforia includes a default image target, and that’s the one we’re going to use for this build. Since it’s good practice to understand dev terms, the image that you’ll aim your phone at to produce an effect is called the “Image Target”. That’s what we’re setting now.
In the GameObject menu, navigate to “Vuforia,” but this time select “Image.” A picture of an astronaut standing confidently on a Mars-like surface should pop into your main window. Unsurprisingly, this image is called “Astronaut.” In the future, you’ll be able to use other image targets. But for now, Astronaut it is.
Import or Create 3D Model
Here’s where you get to import or create your 3D model. If you want to build your own model, do it! You can use it here. Maybe you just want to use a model that comes included with Unity. You can also go with a simple shape instead of a 3D model, depending on the nature of the experience you’re building. Find whatever object you want to use by navigating to GameObject and choosing from the “3DObject” list.
Make your object a child of the image “GameObject” by clicking and dragging it on top of the words “Image Target” in the Hierarchy tab. Then move it in your scene so that it’s on top of or very near to the image.
The next step is to create a printout or print simulation of the image target, so that you can aim your phone at it to activate the AR experience once it’s built.
You can do this any way you want, including just opening a window with the image on another computer screen. But if you want to be able to move away from your computer, you’ll need to print the image target so that you can take it with you.
Navigate through the assets folder to Editor\Vuforia\ImageTargetTextures\VuforiaMars_Images and select the astronaut(Default) image. Print it.
Make AR Magic
You’re done. It was that easy.
Now, let’s save your scene and build this thing. Go to File and click on “Save scene,” then add it to your build scene list by going to File > Build Settings and clicking “Add open scenes.” If there are other scenes in the list, delete them.
After you’ve built the app on your phone, that’s exactly how it will appear: a separate app. Unless you’ve assigned a custom icon, the app will have the Vuforia icon. That’s what you’ll want to look for when it’s time to show off your mad dev skills to your friends.
Cue the drum roll, get your image target ready, and open the app. Revel in your greatness. Then check out our instructions for doing this all over again, but with your own images. Happy building!
- Download and run Unity download assistant and make sure you select Vuforia Augmented Reality Support. (Select your mobile device as well.)
- Create a new Unity project.
- Click on File at the top left then select Build Settings. Now in the prompt that appears click on player settings at the bottom.
- The inspector should now show the player settings. Scroll down to XR settings and expand it so you can then check “Vuforia Augmented Reality Supported.”
- Click the GameObject dropdown at the top and click on Vuforia and select AR Camera. Then Delete the MainCamera from your scene in the Hierarchy tab.
- Go to the Vuforia Developer Portal website and log into your account. In the “Develop” tab, select the License Manager tab and click “Get Development Key.” Copy the license key in the text box. In Unity, search “Vuforia Configuration” and paste the key into the “App License Key” selection, but DO NOT PRESS “Add license.”
- Go to GameObject>Vuforia, but this time select Image (Astronaut by default).
- Create or import a 3D model or just a simple shape from the GameObject>3DObject list and make it a child of the image GameObject.
- Navigate through the assets folder to Editor\Vuforia\ImageTargetTextures\VuforiaMars_Images and select the astronaut(Default) image. Print it.
- Save your scene (File>Save scene) and add it to your build scene list. Go to File>Build settings and click “Add open scenes.”
- To build the app on your phone follow the procedures for mobile app development. Start by switching to Android or iOS development. (If Android: in player settings, uncheck “Android TV compatibility.”)
- Once built, open the app on your phone. Look at the printout, and the object shall appear!