I started playing around with VR projects for Windows Phone back in December. I was thinking that if others could do it on Android and iOS, then our platform deserves some support, too. My initial project used the Google Cardboard for Unity SDK with a few tweaks for Windows Phone support. It was really hacky and I didn’t feel too great about releasing it to the public, even though I did drop it out on GitHub.
I spread that initial hacky version around inside my organization at Microsoft and it garnered some attention and resulted in me connecting with Peter Daukintis, a colleague of mine over in the United Kingdom. Peter had published two blogs posts – one about head tracking on Windows Phone and a follow up post using ALPS-VR for Unity.
Learning about ALPS-VR really opened up my eyes to what was possible with an open, cross-platform VR framework for mobile platforms, so I decided to scrap most of what I had done in my hacky Cardboard-based solution and move forward with ALPS-VR.
So, let’s move into actually building a VR experience for Windows Phone. This assumes that you have some working knowledge of Unity3D and Visual Studio for building Windows Phone apps.
You’ll need a few things:
- A VR headset that can hold your phone – I’ve been using a Google Cardboard headset, since they are cheap and easy to come by. I have found them on e-bay and Amazon for less than $15 USD.
- Download the Unity package(“alpsvr-wp.unitypackage” ) or clone my GitHub repo
- Unity 4.6 (Pro for barrel distortion) – http://unity3d.com/unity/download **Not verified to work with Unity 5**
- Visual Studio 2013 Community Edition – link
- A Windows Phone running Windows Phone 8.1 – I recommend a phone in the 4.5-5 inch range like the Lumia 1020, 930 or Icon. The 1520 and other larger phones don’t fit the Cardboard googles.
Create your Unity project
- Open Unity and create a new 3D project
- Import “alps-vr windows phone.unitypackage” into your project
- Open the “demo” scene file located in Assets/Scenes – this will show you the structure of how a scene needs to be setup – you really just need to drag the ALPSCamera from ALPS/Prefabs into your scene
Select the ALPSCamera object in the scene and scroll down to the ALPSController script component. Notice that there is a Device setting for which VR headset you are using. I have mine set to “CARDBOARD” and the framework will optimize it’s settings for the Cardboard headset.
Build out for Windows Phone
- Open the Build Settings window located in the File->Build Settings menu
Under Platforms, select Windows Store and set SDK to Phone 8.1
- Press “Build” and select an output folder for the Visual Studio project. I usually use something like a Builds folder that sits alongside my Unity project’s Assets folder.
Running the project on a device
This wouldn’t be much fun if you run it on an actual phone in a headset, so place that phone in there with the USB cable connected.
- Open that newly output Visual Studio project.
- Connect your phone to the PC using a USB cable. Make sure the phone is registered as a developer device.
Now, you can run your project on the phone by targeting “Device” and pressing F5. Notice I have my build configuration set to “Master”. This setting yields the best performance, as it removes all of the profiling hooks from the Unity player.
Now that you’ve gone through setting up the sample project, you can venture forth to build your own custom scenes for your project. I would love to see what you build, so hit me up on Twitter to share and I will try to get you some exposure for your project – especially if you publish your app to the store.
You can post questions or comments here on the article and I will do my best to answer them in a timely manner. Of course, you are also welcome to contribute back to the GitHub repo. I will take a look at any pull requests submitted.
I should also mention that ALPS VR has support for Android phones as well, but I haven’t tried it yet. The Android phone that I have is far too old to run it.
***EDIT (5-13-2016) to remove the hijacked alplsvr URL – sorry if anyone clicked on it and was offended!