Introductory AR in Unity 3d using Vuforia
Dr James Birt
Requirements• Unity 5.3 or higher• Android with rear facing camera• Vuforia Developers Account (free)• vuforia-samples-core-unity-5-5-9.zip
Create new Project
Import Vuforia ImageTargets-5-5-9.unitypackage
Creating AR Camera• Drag an ARCamera Prefab
into the Hierarchy• Remove the Main Camera
from the Hierarchy• Click the ARCamera and
view the inspector window
Obtaining a License Key1. Developer Account –
Please read this guide2. Go to License Manager and click
Add License button3. Name your Application4. Choose Device (mobile)5. Choose a licensing option (starter)6. Click Next7. Confirm to Agreement8. Click You Application Name in the
License Manger List
Vuforia Behaviour Script• Copy your License Key to the Vuforia
Behaviour Script App License Key – In Unity 3D
• If using Android I recommend switching the Camera Device Mode to MODE_OPTIMIZE_SPEED If using IOS I recommend MODE_OPTIMIZE_QUALITY
• For now I will leave Tracked Images at 1 but if you want to track multiple images you will need to modify this number
• Leave the rest as Default
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Test License and AR Camera• First Test your AR Camera and
License Key• To do this on Android go File
Build Settings• Then select Android and Switch
Platform• For more details on how to
setup Android with Unity3d please checkout this guide (pg 15)
• Plug in your Android Device to the USB port of your computer
• Click Player Settings
Android Player Settings• Name your Company• Give your Product a Name• You can put an Icon in the Default Icon• Under Identification add your
Company and Product Name to the Bundle Identifier• Now Click Build and Run• Name your APK file• Click SAVE• You Should see a pass through camera
appear on your Android Device with a Vuforia Watermark
Target Manager• You now need to add a Device Database to
your project• In the Vuforia Developer Portal Click Target
Manager and Add Database• Name your Database and select Device• Click Create• Click on your newly created Database• You will notice your Target Database is
empty you will now need to populate your Target Database with AR Markers• Click Add Target
Creating Target Database• There are many types of targets for now
we are only creating a 2D Single Image for Recognition for more details check out the Vuforia Getting Started Guide
• Click Single Image• Choose a picture to convert to an AR
marker for more details on how to choose a good image check this guide
• Width – Leave as 1• Click Add
1
Image Quality• You can see the image I
added is not a great marker scoring only 2 stars• It will still work in the
simulation but will be prone to error• I recommend a 5 star marker
for the best accuracy• If you click on the target
name you can view the features
Adding Target Database• Select All Targets• And Click Download Database• Select Unity Editor and Download• This will form a Unity import package that you can then open and import to Unity3d
Import Target Database
Add AR assets and prefabs to scene• Drag an instance of the ImageTarget prefab into
your scene. This represents a single instance of an Image Target object• Select the ImageTarget in your Hierarchy and look
at the inspector• Look at the Image Target Behaviour script• Under Database select your downloaded database
and under image target select your image from the database for now I will leave extended tracking off if you want to know more about extended tracking and persistent tracking check out this guide
Add 3d object to scene and attach to trackable• As a test create a simple cube object• Add the cube as a child of the
ImageTarget object in the Hierarchy• Move the cube in the scene until its
centered on the Image Target you may need to scale the cube• On the ARCamera Inspector expand
the Database Load Behaviour Script and Load your downloaded Database• Activate the database
Deploy the application• Build out your application• You should have a high quality
printout of the appropriate Image Target infront of you. If not just test with a digital version on your screen• When you look at the target using the
device camera you should see the cube bound to the image