上QQ阅读APP看书,第一时间看更新
Google Cardboard
Building for Google Cardboard is similar, but simpler, than Daydream. Also, Cardboard apps can run on iPhones. You must set up your development machine for Android development as described. Or if you’re developing for iOS, see the next section for details. Then set up your project as follows:
- Configure your Unity Build Settings to target Android or iOS platform.
- In Player Settings, under XR Settings, set Virtual Reality Enabled, and
- Ensure Cardboard is in the Virtual Reality SDKs list.
- Download and Install the Google VR SDK package, as instructed previously.
We will now build the MeMyselfEye camera rig for our scene.
- In your scene Hierarchy, create an empty game object under the MeMyselfEye (select the MeMyselfEye object, right-click, select Create Empty). Name it MyGvrRig.
- Set its height to 1.6 by setting its Transform to Position to (0, 1.6, 0).
- From the Project folders, locate the provided prefabs (Assets/GoogleVR/Prefabs).
- Drag a copy of each of the following prefabs from the Project folder to Hierarchy as a child of MyGvrRig:
- Headset/GvrHeadset
- GvrEditorEmulator
- Leave the Main Camera object under MeMyselfEye and enable it. The GoogleVR uses the existing Main Camera object.
- Save the prefab by selecting MeMyselfEye in Hierarchy, then press its Apply button in the Inspector
When you’re ready, you can build your game as a separate executable app using the following steps:
- From the main menu bar, navigate to File | Build Settings....
- If the current scene is not already in the Scenes to Build list, press Add Open Scenes.
- Click on Build and Run and set its name to Diorama.
- I like to keep my builds in a subdirectory named Build; create one if you want to.
- Click on Save.
An Android APK file will be created in your Build folder and uploaded to your attached Android phone.