Last time, we learned how to make virtual buttons.
First, download assets in our class website.
Now let’s create a new project.
And change the platform to iOS.
Go to the Player Settings, set your company name. And make sure to uncheck ‘Portrait’ and ‘Portrait Upside Down’.
And in Other Settings, set the Bundle Identifier.
Now our build setting is done, next we’ll going to import vuforia package.
Now first thing we have to do is delete the main camera.
And we will bring the AR Camera. (vuforia>prefabs)
Next we have to fill out ‘App License Key’, so go to vuforia website. Copy your license key, and paste to the unity.
And then go to target manager page.
Click ‘Add Database’.
And we will add a target. Select single image, and browse the woodtag.jpg in our asset folder. Width is going to be 50.
Now we got our woodtag target. The target image should be under 2MB.
Download the database, and select ‘Unity Editor’ platform.
And bring the unitypackage to the virtualbuttonDL folder. Organization is important.
Now let’s import the package. And also bring the texture, materials and teapot prefabs.
Create a model folder, and drag teapot inside to that folder.
And in hierarchy, create an event system. (UI > Event System)
And in vuforia prefabs, bring ‘Image Target’ prefab, and place in 0,0,0.
And select our database.
And go to AR Camera, and make sure to face in top view. Rotation 90/0/0.
And add component in image Target. Search virtualButton Event Handler script.
The size is 5. And each of the element will be red/blue/yellow/green/brass.
Next, bring your teapot and drag it inside the image target.
And go to AR Camera, load database and check activate.
And test it.
Nice! And we will going to make buttons activate!
Create empty named ‘buttons’. Bring virtualButton prefab inside the buttons folder, and transform its size. And change its name red button. And drag the folder inside the Image Target folder.
And we will going to add component ‘virtual button behaviour’ script.
And duplicate three more buttons. To modify the position, you have to pull them out of the folder. Make them in right position, and drag them into the image target folder.
And the name should be red, blue, yellow, green. (lower case) The default color is brass.
Now we can change teapot’s color by clicking buttons!
Now I’m going to export to my iPhone!