Lab: Cardboard XR Plugin

Download Links

Part 1: New Project + Github (~8min)

Make sure either Android Build Support or iOS Build Support is installed

  1. New project
  2. Create new Github repo. Add .gitignore to the root folder
  3. Why gitignore? e.g. Library directory is auto generated and can be quite large, there is no need to back this up
  4. Commit & Push

Part 2: Add Cardboard XR Plugin (~11min)

Source: Import plugin from Project Manager, using git

Import Plugin from Package Manager

  1. In Unity, go to Window > Package Manager.
  2. Click + and select Add package from git URL.
  3. Paste https://github.com/googlevr/cardboard-xr-plugin.git into the text entry field.
  4. The package should be added to the installed packages.
  5. Navigate to the Google Cardboard XR Plugin for Unity package. In the Samples section, choose Import into Project.
  6. The sample assets should be loaded into Assets/Samples/Google Cardboard/<version>/Hello Cardboard/Assets.

Understanding Plugin (Hierarchy, Gaze, Input)

  • TrackedPoseDriver: applies the tracked device’s current rotation or position to the transform of the GameObject
  • Camera as Eye & Head, GameObject as Body
    • Eye: controlled by your device
    • Body: controlled by you
    • If you want to move Player from A to B, move Player instead of Camera
  • Gaze: Use Physics.Raycast to send message to the hit object, do dynamic thing
  • Input: screen touch

Part 3: Emulate in editor (~6min)

  • Simulate phone rotation with mouse movement
  • *** At first, push all the changes! ***
  1. Download lab_cardboard_assets.unitypackage
  2. Add VrEditorEmulator to Main Camera
  3. Assign Main Camera to Vr Mode Controller‘s Main Camera field on CubeRoom