7 days of WordPress plugins, themes & templates - for free!* Unlimited asset downloads! Start 7-Day Free Trial

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

2.2 Set Up the Scene

Now that we have our assets together, it's time to bring both Unity and Vuforia into the picture. In this lesson you are going to learn how to set up Unity to use the Vuforia library, and you will learn a little about ARCamera and ImageTargets.

2.2 Set Up the Scene

Now that we have all of our assets put together, let's start to build out our scene within Unity. So first thing that we wanna do is go back into our Unity project that we started to build previously and start to bring in some of these things that we've been building. So, what I wanna do first is, as you can see down here on my desktop, I have a TutsARDemo.unity package which is that unity package that contains my happy image that was uploaded to the Vuforia site. And then I downloaded that target or marker in a database so that I can use it within my project. So all I need to do is double click on it and it's going to open up this very similarly to how it opened up the Vuforia package when I installed it and you're going to see that I have happy right here. And that's gonna be the image and you can kinda pay attention to the location under Editor, QCAR, Image Target Textures, and Tuts AR demo. That's where we're gonna find that image. So we'll just go ahead and click Import and you'll notice that the project assets down here on the bottom have changed. So once again I can go into editor, QCAR, image target textures TutsARdemo and within here you're gonna see that image. But we're not quite ready for that yet. So let's start by setting up our scene and doing a little bit of the basics to bring you Vuforia into our project. So the first thing that you're gonna wanna do is your gonna wanna come up into your hierarchy here and select a main camera and you're gonna want to delete it. So you can right click on it and select delete because we're not gonna be using that particular camera for Vuforia projects when we're doing these augmented reality type things. We're gonna need to use a different type of a camera and we're gonna come down here and choose ARCamera. So as you can see here, I went into the search box down on the bottom and have Assets selected and I can start to search for ARCamera. And as you can see, I get an ARCamera here. So I'm simply gonna click and drag that up into my hierarchy and now you see I have a new camera here. Now you can play around with this manually and start to move things around. But I'm just gonna rotate this ever so slightly in the x direction to be 90 degrees. So you can see where it's pointing here. Now one thing to pay attention to as you're starting to get used to using Unity, there's a lot of controls on here and it can be very overwhelming. But, if you just know some of the basics like up in the top left hand corner, these left two buttons, the arrows in different directions, this is going to be your selection mode. So now I can come in here and I can select different objects. I can drag and I can see the lighting and I can get the camera and I can use this hand to move around in my scene a little bit so I can look. So now one addition to that is if I were to hold down the option key on my Mac, you see it turns into a little eye and now I can change the direction. So I can rotate this around and I can move around. And this is going to make a little bit more sense when we start to bring in some of our assets. But for now just kind of keep that in mind. So we have this AR camera and I'm going to move up just a little bit so you can kind of see it a little bit better like that, okay. So now that we have that the next thing that I wanna do is I need to configure augmented reality. I need to configure this camera in Vuforia using the license key that we generated in a previous step. Now if you don't remember, if you didn't copy it. You can come back over to Vuforia. Make sure you are logged in. Go to Develop tab and then the License Manager. Now under here you're going to see the license that you hopefully created before and if you didn't you should create one now. And I can click on that license and within here you can see a license key. Now without this this whole process is not going to work so you make sure you copy everything within this gray box. So go ahead and copy that. And then with the AR camera selected over here in the Inspector pane on the right-hand side of Unity. You're gonna see under Vuforia Behavior Script and App License Key. You need to make sure that, that is pasted within there. Now that we have our camera and our app license key set up, we can start to bring in some of our assets. So what I wanna do now is I wanna search for something else. And this time I want it to be an image target. So as you see here I have an image target, I'm gonna once again drag that over to my hierarchy. And you're going to see that I have it out here within the same area as my camera. And I have at zero zero zero zero and that should be just fine to get started with, but there's nothing there. What do we want this image target to be? Well with Image target selected, I can come over here on the right hand side to image targeted behavior script. And under database I can select my error demo since that is the database that I imported from Vuforia. And once I do that as you can see here now it is imported that image and since there was only one image target in there. It's selected that one by default. Now obviously if you have multiple images in there. You can select which image you want to use and as I said before when you're building that database you can add as many in there as you want. And when you import that database you're gonna get access to all of those. So you don't just have to use The Happy Birthday image, you could have multiple images that you're going to use for targets or markers throughout your application. So you don't have to just use one, you can use as many as you would like. And this is a good spot where the option click and drag kind of comes in handy. Where I can now kind of move this around and get a a better three dimensional view or I can see what the actual image Is going to look like. So there is what are first and well for this particular tutorial only target image is going to look like. So now we have our basic scene set up and this is really nothing overly interesting. The next thing that we want to do is start to add in our three dimensional object our model that we found of a birthday cake and be able to project it on to this image.

Back to the top