Getting Start With Vuforia & Unity3D to Build an Augmented Reality Application

Preface:

The original artical was first published at sina blog ,and later was republished at Manew.com ,if you'd like to read the original one,please visit http://www.manew.com/thread-96009-1-1.html ,and there you can find not only the artical,but also some updates or Q&As. By the way, the nickname of author is MemoryC, if you find it wrong,perhaps you are reading this from a illegal copy version which would never supply any support.

About Project:

The Version of Unity3D is 5.3.2f1(64bit)
The Version of Vuforia Package is "vuforia-unity-5-5-9.unitypackage",and you can get the latest version by visiting https://developer.vuforia.com.

Main Text


1st

Start a new project in Unity3D like this:

2nd

Import Vuforia-Package into this project, you can just drag your file with suffix like ".unitypackage" and put it in Assets.
Atteintion: Put the file in the path with all the folders of the path nameed in English, or you may fail to import.
Then you can see the dialog to ask you which to import,just select all and wait until it finishes. Then,you can see 2 folders: Plugins and Vuforia.


3rd

Open /Asset/Vuforia/Prefabs to see prefabs of Vuforia, with which we can build our AR Applications.

4th

Delete Main Camera in Hierarchy, and drag prefab ARCamera into the Scene.

Select ARCamera in Hierarchy and check Inspector window


Put your APP Key here , you can get it on official website of Vuforia. On the website, you can see Lisence Manager under Develop table, copy the APP Key and paste into Unity. (chip in:you don't need AP Key if use Vuforia with version under 4)

You need to finish some settings after pasting ,and my settings are like these:

5th

Drag prefab ImageTarget into the Scene.


Then select ImageTarget in Hierarchy and check Inspector, you'd find "No target defines...." under ImageTargetBehavior, poke it to visit officail website, and download your Target Images which you had built before. (Think about building one once you had never built before ).

Select and click download

Choose Unity Editor Platform

Then the download dialog will appear,and you can save your file(with suffix ".unitypackage" ). Don't forget put it at a floder whose and whose parents' are named in English.

6th

Import unitypackage downloaded just now, select all as usual.

7th

Select ImageTarget in Hierarchy and check Inspector again:


You can see there is something changed.
Choose Type DateBase, and choose ImageTarget the one you imported just now.
After that you can see your Scene like this:

Yeah, it is just which you select.

8th

Create an GameObject in Hierarchy, I make a Sphere for simplifying matters.

9th

Make the Sphere to be the Child Object of ImageTarget.


Yeah, you finish it.

10th

Have a enjoy to see the effect.





Exception Handling

About this Part: In my mind, the is the real main text, as I think it more important than the upper main text. You can easily find a tutorial to get start with Vuoria, but you will find it matter to solve so many troubles you meet. I am going to share a summary of trouble you may meet here,.Especially you are new to learn this.

1st

If you are debugging in Editor ,and an error occurs as"Screen is to small to display authorization dialog. Authorization denied ", nothing matters, just adjust the width and height of the Game Window to a wider size.

2nd

When the Script WebCamBehavior.cs binded on ARCamera has an error as "An error occured while trying to enable Vuforia Play Mode" and a warning as "Webcam profiles ensure that Play Mode performs well with your webcam. You can create a custom profile for your camera by editing .... profiles.xml" like the capture below:


For the Error: It occurs for the reason that the version of Vuforia doesn't match the version of the Unity3D, if you use Unity4.x, the error will disappear automaticlly. How to solve it? Do as this:

After moving,the directories look like this:

For the Warning:Open the profiles.xml under the directory, add the manifest discription of your current camera ,refer to the format of extincted manifest discription.

3rd

If you get an error "Failed to load 'Assets/Plugins/VuforiaWrapper.dll',expected 64 bit architecture ... But was IMAGE_FILE_MACHINE_I386 . You must recompile your plugins for 64 bit architecture" as the capture below shows:


The error is something to blame Vuforia for Vuforia supply some invalid libraries. I hope this can be repaired later. How can we do? Don't worry, look at this:

Create a new folder names "x86" under directory "/Plugins/", and move these 4 files into it.

4th

When you publish your application and meet an error “Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. ” , an error caused by Unity5.x,


The way to solve it is opening Unity Ads or IAS service.

As the capture above shows, Click the icon "cloud" to show Unity Services Window, and then using Ads or IAP.

Epilogue:

Getting start with Vuforia and Unity3D is nothing complicated , but it is different when you want to make a product otherwise a demo. For a complete AR producet, you need enough attention, enough programming capability , and the most important :OOP.

For More:

http://www.manew.com/thread-96009-1-1.html
author:MemoryC

MemoryC

Software Designer

Subscribe to CG-HHU

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!