Saturday, July 01, 2017

You and Your Students Can Build Cardboard VR Apps With Unity

I wrote about making your own Google Cardboard apps for iOS with Unity before, but the examples I provided have since become obsolete after the Unity update 5.6.0, which integrated support for VR into its own build tools, and, separately, the Google Cardboard SDK starting with v1.50 was drastically changed, replacing GvrViewerMain with GvrEditorEmulator. The example I had for moving around while pressing the Cardboard button still moved, but the image was flipped over. Talk about a nauseating experience.


I still think it's a worthy goal to develop a working basic example for an almost empty world that teachers and students can add content to and experience it in that special VR way. So I figured out a solution and am offering it here.

Goal

The goal here is for teachers or students to add 3D content to a simple world, and build and install an app on an iPhone or iPod Touch so that world can be viewed in a Google Cardboard device. The app will allow the user to press the Cardboard button and move in the direction they are looking, effectively giving the experience of walking around in the environment created in the app.

Install Unity

Go to Unity3d.com and download the installation assistant for Unity Personal, and install Unity. Make sure to include the hefty iOS tools, which will push the installation over 1 GB. You have to create an account, which is easy and free. For younger students, say upper middle school, you will want to set all this up yourself on whatever computer they use. High school students could create their own setup on their own computers if they have hard drive space.

Install XCode

The build process involves Unity handing the job over to Apple's XCode to verify you and your connected device. XCode is a nearly 10GB application at this time and the setup is not something you want you put students through, unless they are interested in the challenge. What I do is compress each student's project to a zip file (700MB-1GB each), open it on my computer, and build it there, installing it on one of a collection of devices our school has, like a set of iPod Touches. To set up your own installation of XCode, go to https://developer.apple.com, sign in with your Apple ID, and download and install XCode. You can get it from the App Store app as well. You do not have to purchase the $100/year developer license to "side-load," or install over USB, an app onto a device, but without the paid license the app will expire after 7 days. Once XCode is installed, click XCode > Preferences and sign in under Account with your Apple ID. This will be used to "sign" the app during the build.

Build A VR App

Download this project, called Walking Template, and unzip it. This project already includes a version of the Google Cardboard SDK, not the most recent, but one that will work for a while with Unity. It still uses the GvrViewerMain prefab, without which I can't get the walking to happen correctly. Open Unity and open the project. Before messing around with Unity, just try building it. 
  • Click File > Build & Run
  • It will take a minute but eventually XCode will open. If it doesn't come to the front, switch to it manually. 
  • XCode usually hits a signing error snag and does not complete the installation to your device. You must select your own Apple ID in the Signing Team, then build again from XCode, clicking the run button.

  • If the app successfully loads on your device, CONGRATULATIONS! Consider yourself lucky and enjoy pressing the Cardboard button and walking around. It can often involve a lot more troubleshooting before you get this far.

Customizations

I will cover adding content in other posts, but one thing you should know how to customize are things like the app name, icon, and author. To change those, in Unity go to File > Build Settings, and Player Settings. Under Company Name you can put yourself. Product Name is the name that will show under the app's icon on the device. You can add a different icon by making a 100 X 100 px image, drag it into the Assets pane, then drag it into the Default icon box in the settings. Below that in the Inspector panel there are a number of other settings for iOS. Some of those I have pre-selected to make the build in XCode go more smoothly. One you can change is Bundle Identifier under Other Settings. Software is typically identified with a sort of reverse URL nomenclature, like com.yourname.appname, or org.yourname.appname. You might also notice that there's a checkbox for Virtual Reality Supported and it would seem to make sense to check this. But don't. This is indeed the VR integration into Unity I mentioned, but it doesn't build properly with the older Cardboard SDK I've used, only with SDK versions 1.50 and 1.60. Google doesn't seem to be offering functionality people can't get in other ways with the new tools, so hopefully this setup will last for a while. 

Now What?

Like I said I will give more details about what to do in this space in the next post, but there's lots of fun stuff to do with this template, from importing 3D content, to changing the terrain textures and shape, and skybox lighting.







No comments :