Cosc 5/4735 Unity and Cardboard VR
Unity3D and Google VR Much like OpenGL, android has produced a “plugin” for unity. You can use the asset at the start or add it in to already formed project. Directions assume Unity 2017.4.0f1 Download gvr package for unity https://github.com/googlevr/gvr-unity-sdk/releases
Adding VR to unity Assets -> Import package -> Custom Package Find the GoogleVRForUnity…unitypackage file (where you downloaded it) Import everything. Existing project: Select the camera (either MainCamera or FirstPersonCharacter Camera) From menu, Component -> Google VR->Update Stereo Cameras You now have Cardboard ready cameras.
Adding VR to unity (2) For a new project Delete the MainCamera and add the GvrMain prefab It has everything to control the VR mode.
Play mode in Unity. Mouse-based head tracking: if you press Alt and move the mouse around, you can pan horizontally and tilt vertically around your scene as if your head is moving Cardboard around. Use Ctrl with the mouse to simulate tilting your head from side to side. Simulating trigger pulls: use a mouse click to simulate the action of a user using the trigger.
Trigger Pulls Add the following script: public class NewBehaviourScript : MonoBehaviour { public Text textView; void Update() { if (Cardboard.SDK.Triggered) { //deal with trigger here } } } Add the script via the Add Component button Likely to the FirstPersonCharacter.
A note Build & Run on unity If you get Key error, it’s a known problem in unity3D. It’s having problems with the data connection to that phone. Works on my Moto G, fails on the Nexus 5X Try just Build. Cmd prompt: adb install –r file.apk -r is replace, so you can do it multiple times with the same version number.
References https://developers.google.com/vr/
Q A &