Cosc 5/4735 Unity and Cardboard VR
Unity3D and Cardboard 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. – Download cardboard sdk for unity unity/blob/master/CardboardSDKForUnity.unitypackag e?raw=true unity/blob/master/CardboardSDKForUnity.unitypackag e?raw=true
Adding VR to unity Assets -> Import package -> Custom Package – Find the CardboardSDKForUnity.unitypackage file. – Import everything. Existing project: – Select the camera (either MainCamera or FirstPersonCharacter Camera) From menu, Component -> CardBoard->Update Steoro Cameras – You now have Cardboard ready cameras.
Adding VR to unity (2) For a new project – Delete the MainCamera and add the CardboardMain 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 ty/ ty/
Q A &