Recently we converted our app into an Oculus GO app, we wanted to explore what is possible in VR and see for ourselves how easy it is. In fact building your own Oculus VR app is very easy, to make it even more easy I prepared a Unity Package, that you can import and put your own content in. You don’t really have to be a programmer to get started.
However I also have to note the Unity package is not really programmed very well.
Please email me when you have questions or need help at firstname.lastname@example.org
We also tried to publish our app to the Oculus store, unfortunately it didn’t get accepted to the Oculus store. In the process of preparing our app for the store we ran into a small problem with Unity, the used version of Unity could not sign the Android app. The problem and workaround is documented over here.
Oculus GO APKs have to be signed with the APK Signing Scheme v1, unfortunately this isn’t supported by all Unity versions. I struggled a bit figuring this out so I thought I might document it on one site.
Instead of the signing the APK with Unity you will have to sign the APK yourself using Gradle.
Preparing your apk in Unity
You can use Unity to prepare the signing process and obtain the AndroidManifest.xml as a help. Go to the Build Settings in Unity and configure the project how you want in the Player Settings.
Signing it with Gradle
You can then use the exported project to build and sign the APK with Gradle. The exported project contains a prepared AndroidManifest.xml and a gradle.build file where you can configure the signing options.
This is the signing part of the gradle.build I used:
For anyone that wants to start right ahead in Cardboard development with Unity I made a unitypackage, that serves as a good stepping stone for developers. You can download the unitypackage below. The package contains a Unity-Scene with everything necessary for Android Cardboard development. You just need to insert your own objects into the scene to get a cool looking Cardboard app.
The scene contains a player object, that controls the camera and processes the user’s head movement. The player object simulates the user in the scene and let’s the user explore the world with the different movement modes (flying, fast-flying, walking, standing and teleporting) described in other articles.
Furthermore the scene contains a few other things to make it more immersive and lively from the start on. This includes a skybox and a water object, that works in Cardboard VR.
Using the Unitypackage
When you have the package downloaded, create a new Unity project using Unity 2018.3.14f1 and import the unitypackage by navigating to Assets\Import Package\Custom Package in the main menu. Then select all objects to be imported.
Navigate to the Scenes folder in your project’s Assets folder. Double-click on navigationBarScene, you will then have a prepared scene with a skybox, a PlayerObject, a water object and all necessary prefabs from the Google VR package. Everything in the scene is ready for Cardboard VR, you can add your own objects and more into the scene and export it for Android Cardboard or Daydream.
In this article I will write about Android Cardboard development using DAE files obtained from an OAR, the files are generated with a free tool, you can read my article about it here. This article includes tips, tricks and references to files needed to create an interesting Cardboard app.
For your own convenience you can download a package containing a ready made scene at the bottom of this article. The scene contains a player object and anything else needed for Cardboard, just download it, insert your objects into the scene and export the Unity project as an Android apk for Cardboard.
Android Cardboard development with Unity requires Unity “Version 2018.3.14f”. Unity with different versions properly generate the APK file without errors, however the installed app then fails to react to Cardboard user input (head-movement).
Importing the DAE files in Unity
You can follow the guide here (link the old one). To reiterate, you have too place the SelectOARShader.cs script in the Editor subfolder in your Assets folder, then place the DAE folder in the Assets folder and let Unity process them. You can then move the objects from the DAE folder in Assets into the “Hierarchy View”. Finally if there are errors with transparent textures in the Scene you have to set the object’s materials to “Use External Materials (Legacy)”, you then have to change the shader of the object in the “Hierarchy View”. For example a suiting shader is “Legacy Shaders/Transparent/Bumped Specular”.
Setting up Unity for Android Cardboard
To use Unity for Android Cardboard Development we first have to install the tools required for Android development in Unity. First, add the Android module to your Unity version 2018.3.14f, to do this you go to Installs in Unity Hub, then click Add Module and add Android.
Then you have to switch the Unity project’s platform to Android, go to File/Build Settings, select Android on the left, click “Switch Platform” and wait for Unity to change platform.
After you switch the platform to Android for the first time you will also have to add an Android SDK and NDK when you try to build an APK. When you are prompted to do so, just select the SDK and NDK you have downloaded previously. (link to them here)
Cardboard Development prerequisites
For Cardboard Development I recommend you set the orientation of the Android device to “Landscape Left”, these settings can be found in the Player Settings. Furthermore you have to add Cardboard in the XR Settings.
Next you will need to import the Cardboard SDK from Google, simply download the SDK (a Unity package) and import the package. You will need to copy a few prefabs/objects from the GVR SDK into your scene, GvrControllerMain, GvrEditorEmulator, GvrEventSystem and GvrReticlePointer.
The GvrReticlePointer should be placed as a child object of your scene’s Main Camera, this prefab provides you with a dot in the middle of the screen, showing the position of the gaze to the Cardboard user. It also ensures your camera changes orientation depending on the user’s head movement. You should also add the GvrPointerPhysicsRaycaster.cs script to the Camera.
From this point you should be able to generate an App, where the user is at the position of the Main Camera and can look around by moving his head. If you imported the DAE objects the user can look at them but he cannot move or interact with them at all, this will be covered in the next section.
The pointer from the GvrReticlePointer prefab can be used to interact with in-world objects by setting event triggers on objects, for example a Pointer enter or Pointer exit trigger. This can be used in many ways, you can for instance program a button, that moves an object when the player looks at the button (Pointer Enter trigger).
However we want to do more than just buttons, we want to move in the Virtual Reality, maybe we also want to fly or do anything else.
To make the player move around you could move the Camera object around based on where the player is looking. To do this you can read out the Camera’s orientation and use it as input to your game. Alternatively you could move the player around if he looks at certain objects, like in a click adventure game.
For the app “The Faked VR” I built an interface for the user, that combines the two ways. The user is moved based on where he looks and what buttons he looked at previously. The user will see an interface when he looks downwards where he can select his movement mode from the buttons. The user can chose to “Fast Fly”, “Fly”, “Move” or “Stand”. These buttons change how the game will interpret his head movement. In case he choses one of the two flying modes the player/camera is moved in the direction the user looks at. In case he choses the “Move” mode he will move where he looks without really changing his height, this mode is ideal for walking around and looking at objects. The last real movement option is not moving at all, if he choses to stand the player will not be moved at all, he can stand still and look all around without changing position.
Furthermore there is a “Teleport” button, that teleports the player to the starting position. This button can help the player get back if he gets stuck anywhere or does not wish to go back himself.
To make the navigation bar responsive I made the buttons change colors when they are selected. Furthermore I made the reticle in the middle of the screen expand for a bit when the mode was changed.
In the app the player has to focus each button for a bit before the mode is changed, this ensures the player doesn’t select a mode he doesn’t want unintentionally.
Furthermore there are a few objects in the world that the player can interact with, the player can look at them for a short duration and is subsequently teleported away. These objects can lead the player around the world or to secret spots he would not likely find himself.
I made this navigation tool freely available at the bottom of this article, go there for more information and a download link.
Cardboard tips and tricks
Adding a Menu: If you ever try to use a menu for a Cardboard app, make sure the Canvas’ Render Mode is set to World Space. If the Canvas is placed somewhere in your world, it will appear to Cardboard users like a billboard in real life. Alternatively you can attach a Canvas to the player’s GameObject and position it relative to the camera.
Adding Water: To fill up the world and to make it more lively you can commonly add water and turn the contents in the middle into a nice looking island. Unfortunately the standard water does not work with Android Cardboard, it may look good in the Unity editor but not on the actual phone. The default water has wrong reflections in Cardboard, which completely destroys the immersion. Luckily there is a solution, you can use the Water from here. Simply add the files to you Assets folder and move a water prefab into the object, then make the water object bigger and move it where you want. The Water object is in the downloaded subfolder under WaterVRTest-master\Assets\Standard Assets\Environment\WaterVR2\Prefabs.
Adding a Skybox: On a similar note you can add a skybox to your world, you will need a few textures and insert them in Unity. You can get a lot of skybox textures on the internet, I got mine from here. Click here for the very good official documentation.
Above you can download a unitypackage with a scene, that includes my navigation tool, a nice skybox and a good water object. The scene is a ready made environment, you just have to insert your DAE files and create a game world in the scene. Without any programming you can create an app where players can explore your world in Cardboard VR.
When you have the package downloaded, create a new Unity project using Unity 2018.3.14f 1 and import the unitypackage by navigating to Assets\Import Package\Custom Package in the main menu. Then select all objects to be imported.
Navigate to the Scenes folder in your project’s Assets folder. Double-click on navigationBarScene, you will then have a prepared scene with a skybox, a PlayerObject, a water object and all necessary prefabs from the Google VR package. Everything in the scene is ready for Cardboard VR, you can add objects into the scene and export it for Android Cardboard or Daydream.
In this article I will be writing about how to import DAE files in the Unity game-engine, more specifically DAE files obtained following the instructions in my guide “How to convert an OAR to DAE files”. For reference, the DAE files are created by a program from an OAR, the program handles such things as textures, mesh models, sizes and coordinates of objects from the OAR.
When you want to import the DAE files for standard Unity, you can use the Unity version you prefer. However if you want to use Unity to produce a Google Cardboard app you will need a specific version, we found success with “Unity 2018.3.14f1”. Other versions built the Android application without errors but didn’t properly respond to input on an actual Android phone.
Before you import the DAE files into your Unity project you should import a script SelectOARShader.cs into the Editor folder in the Asset directory of your project. The script comes with the OAR-converter tool in the folder Unity3D. To import the script, you just have to copy it in the right place, Unity will process the new script and show the progress with a green bar that fills up.
To import the DAE files you have to move the entire DAE-folder into the project’s asset folder. You will see a similar progress bar, just like when you copied the SelectOARShader.cs script. When the objects are imported you can select the objects in the DAE folder in your project and move them into the “Hierarchy view”, this imports them into your Unity scene. There may also be objects in the Phantom subfolder, depending on your converted OAR. These objects can be copied into the “Hierarchy view” by dragging and dropping as well.
Fixing transparent textures
Some textures with transparent parts may look foggy in the objects in the Hierarchy view. In other words some transparent textures may not be properly transparent. You have to follow the procedure for each object, that is not properly transparent. To fix this you have to click on the corresponding object in the asset folder, then select the material tab, go to Location and select “Use External Materials (Legacy)”. You can then go to the Hierarchy View, select the object, go to the shader and select a shader, that properly renders the transparency. One of these shaders is called Legacy Shaders/Transparent/Bumped Specular.
The next article will deal with importing the DAE files in Unity for Android Cardboard app development, I will provide some useful files and tips and tricks.
Opportunities for DAE files in Unity
The imported DAE files can be used for almost anything. You can use the objects for games, animations, VR apps and much more.
In this article I will show you how to convert an OAR to a collection of DAE files. We will be using a tool by Fumi.Iseki, Austin Tate, D.Mizumaki and K.Suzuki, you can read up on the tool on the Tokyo University of Information Science’s website. All credit goes to them for creating this convenient and powerful program. Accompanying the written descriptions there will also be screenshots detailing the steps.
How to setup/install the converter
The converter is available for Windows and Linux, I prefer using Linux and will explain how to install and use the tool on a Linux system. Don’t worry, the installation is not difficult at all, I will also explain how to get a Linux system in this guide.
How to install a Linux system on your PC
First of all we have to install a program, that can simulate a Linux system. I recommend using VMware, it is free and easy to use.
When you have VMware or a similar program installed you have to create a Linux system, I used Ubuntu 18.04.3 and used this .iso file to set the Ubuntu system up. The first start of the Ubuntu system may take a while.
Downloading the converter
When the Linux system is ready, go to your home folder and open the terminal. On Ubuntu you can open the terminal by right-clicking in the explorer and selecting “Open in Terminal”. You can then install the converter by typing the next two commands in the console and then hitting the enter key.
The first command downloads a .zip folder that contains the converter and the second command extracts that very .zip file. Alternatively you can also manually download the .zip folder and then unzip the file using the command in terminal or manually.
The converter also needs another library, it can be installed with a simple command in the console, the command then requires you to input your password.
sudo apt-get install libjpeg62
Furthermore before we can execute the converter we have to create a symbolic link, the symbolic link ensures that the converter can find a library it needs for execution. The library is referenced under /usr/lib/libcrypto.so.10 by the converter but in the Ubuntu system as /lib/x86_64-linux-gnu/libcrypt.so.1. The link might be different or not needed if you use a different .iso file to install Linux.
To set this symbolic link up you just also have to enter the next command in the terminal you opened before.
Before we can run the converter we have to extract our OAR file and put all the content of the OAR file in one folder. Imagine we have an OAR called my_art.oar then we can create a folder called art_oar and extract the content to the folder with the following commands in a terminal.
tar zxfv ../my_art.oar
These commands move our terminal into the OAR folder, in our case art_oar, to step back out of the folder we can enter the next command or reopen a terminal in the parent folder.
Converting an extracted OAR to DAE files
Finally we can use the program to convert the folder, in our example art_oar. To do so we enter the next command in the terminal. The first argument is the location of the oarconv.sh file, the last argument is the name/location of the folder that we want to convert.
./oarconv/oarconv.sh -i art_oar
The converter creates a folder called DAE where you executed the command, that folder contains everything in the original OAR converted to DAE files, textures and more. You should note, that there are a few particularities. The converter is not able to convert scripts from the OAR. Every object in the DAE folder has a suffix of 50 characters, this suffix is the ID of the original object in the OAR.
The next guide will explain how to import the DAE files to Unity and some experiences and issues I encountered.