In this tutorial, we would create a AR environment with Vuforia Engine in Unity. Vuforia provides a basic free AR system that allows users to create some function of AR easily.
To start with Vuforia, first you need to Unity Assets Store, and add Vuforia Engine to your assets.
After adding it, you can import the package in Package Manager of Unity.
Once done, there should be a Vuforia Engine section in the GameObject dropdown menu.
Then add an AR Camera and delete the main camera.
Select the AR Camera and click Open Vuforia Engine configuration in the Inspector.
Inside the configuration window, click Add License to create a license, and also disable “Delayed Initialization”.
When you click the button to add license, it should take you to the website of Vuforia Engine. After creating an account, click Get Development Key button.
Set a name to your development key, and check the agreement of using Vuforia Engine.
In my experience, I have waited for a license key to show up in my developer page for at least 5 days after I applied for one. I do not know if this is an issue of their website but after I wrote a mail to them, I got the key immediately.
Just for your information in case you happened the same issue like me.
You should see the key in your developer page.
Select it and you will see a serial key. Copy it and paste to Inspector of Vuforia Engine configuration window.
Get your own AR image target
Now we can add a AR image target.
At the middle of Vuforia configuration window, there is a Database section. Click Add Database and it would open another website.
Click Add Database and select “device”, then set a name to it.
When you back to Target Manager page, select the database and click Add Target button.
Select Single Image and upload an image from your device.
You can set any width you want, give it a reasonable width.
After adding a target, we can back to Unity to use this target.
Add an Image Target object from GameObject> Vuforia Engine> Image Target.
Select it and select “Type” to “From Database” in Inspector, and you should see the target that you just created.
Placing model in a real world
You can import any model or simply create another 3D gameobject. Then make it a child object of Image Target. Also, set it to the position you want and that would shows on the same position when you scanning the image target with your camera.
Here is how it looks like if everything works perfectly.
Or you can open the demo scene of Vuforia Engine package to get a better look 3D model as demonstration.