Professional Documents
Culture Documents
blogs.windows.com
Today, we will show you how to create a new Unity project and
develop a real AR experience from scratch for devices running
Windows 10.
You can download the source for this application here, but I
1 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
2 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
1) Creating a license
After logging in click Develop, then Add License Key:
This will take you to a form where you can set the details of this
license. They can be changed and removed later.
3 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
Fill out the form that pops up. It is needed to create a database for
our markers. This database will be downloaded and added to your
app locally – on the device itself – so select Device as the database
type:
A new form will show, where you will need to select the image you
want to use, its width and a name. Select the magazine front cover
I provided earlier, set the width to 8.5 and name it cover1. Click Add
4 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
Done! Next, we will create a new Unity project and add the Vuforia
SDK to it.
If you don’t have Unity yet, you can go ahead and download it here:
http://unity3d.com/. A free personal license is available.
5 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
When the project is created, we need to import the Vuforia SDK for
Unity package. It can be downloaded from here (take the latest
version): https://developer.vuforia.com/downloads/sdk
Once extracted, a popup like this will show. Click Import to add the
Vuforia SDK to your project. Your solution should look something
like this:
Now that we have the Vuforia SDK installed, the last thing we need
to do is to add the marker database we created earlier to our
6 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
project.
Once compiled and downloaded, you can just open the Unity
package file to import it to your project:
You can see from the import dialogue that we got the cover marker,
as well as the database itself. Click Import and you are all set to
start developing!
7 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
Now that we have the Vuforia SDK installed as well as the markers
we need, the fun can begin.
Vuforia comes with a set of drag and drop assets. You can take a
look at them in the Vuforia/Prefrabs folder as seen below:
Another thing we will need is the target itself. This is the prefab
named ImageTarget, and it is also configurable. Let’s go ahead with
the development.
a) Add camera
8 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
9 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
To test, click the play button on top of the scene view. You should
be able to see what the camera sees and the Vuforia watermark:
10 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
a) Adding an ImageTarget
Adding an ImageTarget is as simple as adding an ARCamera, just
drag and drop the prefab to the scene hierarchy view:
11 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
Navigate to the folder for your asset, then drag it (or its prefab) onto
the ImageTarget so it becomes a child of the ImageTarget.
Looking at the scene view, you can now see the magazine cover
with the boat on top of it:
d) Testing if it spawns
Let’s go ahead and run the app again. Place the magazine on the
playfield (in front of the camera) and the yacht will become visible
12 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
e) Adding details
You can add even more things to the scene, like water, and can
change the lighting so your scene becomes more realistic. Feel free
to play around with it.
3) Exporting as a UWP
From this dialogue, set the Platform to Windows Store and the SDK
to Universal 10 and click Build. A new dialogue will ask you to
select a folder to export to; you can create a new one or select an
existing one – it’s up to you. Once the export is done, a new UWP
Solution is created in the selected folder.
Once Visual Studio 2015 has loaded the solution, set the Build
13 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
Configuration to Master and the Platform to x86, and build and run
it on your local machine:
Let’s also add a simple user interface to the app using XAML. To do
this, open the MainPage.xaml file from the project tree and view the
code. It should simply consist of a SwapChainPanel with a Grid in
it, like so:
<SwapChainPanel x:Name="DXSwapChainPanel">
<Grid x:Name="ExtendedSplashGrid"
1 Background="#FFFFFF">
2 <Image x:Name="ExtendedSplashImage"
3 Source="Assets/SplashScreen.png"
4 VerticalAlignment="Center"
HorizontalAlignment="Center"/>
5
</Grid>
</SwapChainPanel>
You might also want to decorate the screen with a logo and some
lines to make the UI look neat and clean. To do this, we need a file
from the downloadable source (/Assets folder) called
SunglobePatrick26x2001.png. Add this to your solutions Assets
folder.
14 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
this:
<SwapChainPanel x:Name="DXSwapChainPanel">
<Grid x:Name="ExtendedSplashGrid"
Background="#FFFFFF">
2
<Image x:Name="ExtendedSplashImage"
3
Source="Assets/SplashScreen.png"
4
VerticalAlignment="Center"
5 HorizontalAlignment="Center"/>
6
</Grid>
7
<Rectangle Fill="#FFF3C000"
8 HorizontalAlignment="Stretch" Height="3"
9 Stroke="#FFF3C000" VerticalAlignment="Top"
11 <Image VerticalAlignment="Top"
16
<Rectangle Fill="#FFF3C000"
17 HorizontalAlignment="Stretch" Height="3"
Stroke="#FFF3C000" VerticalAlignment="Bottom"
Margin="24, 0, 24, 64"/>
<CommandBar VerticalAlignment="Bottom"
15 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
IsOpen="True" Background="#00000000"
Foreground="#FFF3C000" Margin="0,0,18,0">
<AppBarButton Icon="Edit"
Foreground="#FFF3C000" />
</CommandBar>
</SwapChainPanel>
What we’re doing here is using the XAML tags to add two
rectangles, used as lines, for a minimalistic UI, as well as adding
the logo for the boat.
Run the app again to see the UI on top of your rendering canvas:
Wrapping up
16 of 17 7/6/2019, 6:45 PM
How to develop augmented reality apps with Vuforia for Windows 10 about:reader?url=https://blogs.windows.com/windowsdeveloper/2016/10...
The Windows team would love to hear your feedback. Please keep
the feedback coming using our Windows Developer UserVoice site.
If you have a direct bug, please use the Windows Feedback tool
built directly into Windows 10.
17 of 17 7/6/2019, 6:45 PM