In this section we will be testing different applications of virtual reality content creation and we show you our experience with them.
Unity and Android Studio
Unity is a multiplatform video game engine created by Unity Technologies. Unity is available as a development platform for Microsoft Windows, OS X or Linux. We will use Unity 2018.3.13f1.
Android Studio is the official integrated development environment for the Android platform.
We will also need the Java SDK that we will download and install from their page.
In the screen of selection of the SDK we marked Android 6.0 (API 23) since we will test in a mobile with Android 7.0 and we want them to be compatible. You can download more later from the Android Studio SDK if necessary.
We will open the Unity program and create a new project. We will name our project and click on Create Project. After a few seconds the program will load.
The first thing we will do is verify that the Android Studio route is well established. For this, we will go to Edit -> Preferences. We will also change the color of the mode run (modeplay).
Now we will configure the Android options in the File -> Build Settings menu. Click on the Switch Platform button that will change the name of the button to Build.
Then we will enter Player settings where we will establish some options. We will put the name of the company and the product that we want, as well as the name of the package.
Another option that we can change is the minimum level of API to Android 4.4.
We will go to the XR settings option and mark the virtual reality option and add the Cardboard SDK.
We will also add an icon for the application on Android. First drag an image to the assets directory and then drag and drop it on the Default icon box.
We will download and import the GVR SDK package for Unity here. This package incorporates numerous tools for the creation of virtual reality. Once downloaded, we will go to the Unity Assets-> Import Packege-> Custom package option, and select the downloaded packete.
We will install the tool GVR Editor Emulator and GVR Controller Main. We will look for both names in Unity and drag and drop both packages to our project.
With these imported tools we can move around the stage if we click on play and then hold the Alt key and move the mouse.
We exit the game mode by pressing again on play.
Now we will incorporate a 3D object (in our case a cube) to our project through the menu GameObject-> 3D object-> Cube.
This cube element can be moved, scaled, or rotated, between other transformations.
We will now create a Materials folder in the Assets directory and within this folder we will create a material, in our case it will be the Virtual Pin Pan logo. For this we will click on the assets, create-> Folder and create-> Material.
To put our logo on the cube will drag the material and we will release it on the cube object.
Now we will create an observer’s visual to be able to visualize our object when we click on play.
We create an empty object by clicking right-> Create empty on our project. Next we will drag the Main Camera element on this new object. Finally we will name this empty object: observer.
We will now modify the camera so that it looks at the cube object. For this we will press on Main camera in our project. In the Inspector we will right click on the name Transform. In the menu that appears, we will choose Reset, returning the camera to the center of the cube. Now having the observer object selected, we will move the camera so that it observes the cube.
If we press now on play we will observe our cube object.
We will create a room with the Cube Room tool. We will look for it in Unity, we will drag and drop it on our project. we will select the cube and we will move it to place it where we want.
We are going to add functionality to be able to interact with our object. We look for the GVR Event System and GVR Reticle Pointer tools and import them into our project. Reticle Pointer (in play mode you will see a white dot) we will drag it to the Main Camera.
To be able to interact with the object we must import the Gvr Pointer Physics Raycaster tool. This tool throws rays to see the objects it intersects with.
We add an Event Trigger component to our cube. This will cause an event to occur when the camera’s rays strike the cube. The event may be that a song sounds, a video is played, etc. In our case we will have a video played. The first thing is to drag the video to the Assets folder.
Now we will create an object (right click on our project-> create empty) which we will call videoaventura. We will drag our video to this new object.
Now we select the cube and add an event when we pass the pointer of the camera through the cube. The type of the event will be Pointer Enter. Once created, we will drag the video to this new event and select the Play function. That is, when the camera points at the cube, the video will be played.
The video will be played on a flat object. To create it we will go to GameObject-> 3d object-> Plane. Now we will transform it so that it is between the camera and the cube, as in the image.
We will right click on the project and create an empty object (we will call it the screenvideo).
We will drag the video player on this new object. We will draw the plane on the Renderer property of the videoplayer object.
If we click on play we will see how the video is loaded when observing the cube. And with this we would have configured our scene.
Let’s save our project and create the .apk file to run on Android.
In the File-> Build Settings menu, click on add open scenes and then on Build. We select the name and directory of our Android application and ready.
Now we will install and test our application on the mobile and Cardboard. The results are the following.
We could also have downloaded some 3d object from free3d.