Display image on an image target using Easy AR IN Unity 3D
Modern technology that displays digital world in real world is Augmented Reality. In this blog we are going to learn about displaying image on an image target using Easy AR in unity 3D. The video below will help you for better understanding of this blog.
For better understanding make sure to read the previous blog i.e, DISPLAY 3D MODEL ON AN IMAGE TARGET USING EASY AR.
Create a new unity project:
In augmented reality creating a new unity project requires some of the things to be done. For creating a new unity project you need to write project name and then click on create project.
Go to EasyAR:
After creating new unity project, we need to go to EasyAR and go to download. After that go to unity packages and click on EasyAR Sense 3.0.1- final Basic_unity.zip and download it.
Now we need to go back to the develop center and add SDK License Key.
Check in the EasyAR SDK Basic and write the name in ” APP Name”. We are making for Android. That’s why we are writing package name as com-zeanex. easyar test. Now click on confirm.
Go back to unity:
Go back to unity and go to file. After go to file we need to click on build settings and change the platform to android. Click on switch platform and then go to player settings. In player settings go to other settings and paste the package name. For pasting the package name, copy the package name from easy AR and paste the package name in unity.
Copy and Paste License Key:
Now go back and import that which you have downloaded. After that drag in assets folder in unity and click on import. Its imported now. Click on Easy AR then click on common. After clicking on common, click on resources. Now click on Easy AR and then click on inspector. Go back to the website of Easy AR and copy that key which we have created and paste that key in the script in the Inspector.
Go to Package name:
After pasting license key next thing is that we have to use the package name in case of using this licence key. So go to file, then go to build settings and then click on player settings. After clicking on player settings go to identification and in identification you can see the package name. Copy the package name from Easy AR develop center and paste that in unity in the option of package name. Now go to console and clear that.
Displaying image on an image target:
The next thing is to display image on an image target. So go to assets then go to samples and then go to scenes. Then go to HelloAR_Image Target.
Copy this scene in assets for easy assess. Now open this scene. In this scene you can see there is an image target and a Quad. Now go to Inspector and then click on Element 0 in Mesh Renderer. After clicking on element 0 you can see name card. Now click on name card.
Quad is already used to display an image and the cube is 3D model. So, we will delete the cube but we need the Quad. Quad is already displaying the namecard Image that is placed on the material. So we will just change the image . Now we will take our image from the desktop and change the Albedo here. Then this Quad will show the image that we put onto it. Drag the image in the textures in the unity.
Now in Quad go to materials . Then click on Albedo and select the texture. In order to change the image target we will bring our own target in the streaming assets folder. We will drag the target 2.jpg in the streaming assets folder. Now go to image target and name it. Target name and target path will be same only we need to add .jpg with the target path.
Our image is stored as streaming assets. Now you can see that the Quad attach image is having black background . To remove that go to its settings. Now go to sprite (2D and UI) and click on apply.
Now we need to go back to the Quad and check the material and black background has removed now.
Setting Quad size:
We will now set the Quad size according to our requirements. You can set scale, rotation and position according to your choice. In order to not to show the background, we also have to change the opaque rendering mode to transparent rendering mode.
From top menu click on file, then click on build settings. Check the platform is android if not switch it. And then click on add open scenes. Now click on player settings. Go to other settings. Change the package name according to your choice. Unchecked x86 and Android TV compatibility. Change the stripping level to low. Click on XR settings and make sure vuforia augmented reality is selected. And then you can insert the icon of your app. That’s all for settings now connect your android mobile with your computer and click on build and run. Now name it and save it.