Unity3D Non-VR to VR Porting Tutorial

1. Create a new Unity3D Project

2. Go to Asset Store and Import Standard Assets Package

3. Open the scene CharacterThirdPersonAI

  • Bake NavMesh

  • Play the scene and left-click, a target logo will appear where the mouse clicks, and the character will move to that position.

4. Import QWR_VRone_SDK.unitypackage

The QWR VRone SDK is based on Unity 5.3.0. If you are using a later version, Unity will prompt you to upgrade API when importing the plugin.

If the upgrade window does not pop up automatically, please close the project and reopen it.

5. Unity Settings

  • Follow Unity Project Settings guide and complete the project settings

  • Find the Game Tab and add an Aspect Label (1024 x 1024). The aspect ratio of a single eye is 1:1

  • Please select Android platform and Switch Platform.

6. Replace Camera with QwrCameraRig (Assets/QWR/Prefabs/QwrCameraRig)

Developer needs to decide whether to replace the Camera object directly, or to use QwrCameraRig as a child object. In this example, CCTVCamera has many other functional components, so QwrCameraRig is used as a child object.

  • Find CCTVCamera (Main Camera)

    • Modify the location of the Camera

    • Uncheck Camera related items

  • Use QwrCameraRig as a child of CCTVCamera.

Play the scene. Hold down the Alt key, move the mouse around with the right mouse button pressed to look around. A ReticlePointer is added to the center of the scene.

7. Replace the touchpoint of a touchpad, or the location of the mouse with the ReticlePointer position.

However, VR apps are different in interaction from traditional desktop or mobile apps. After wearing the HMD, you can only see the objects in the VR scene, you can't see the mouse or the touchpad. It is inconvenient to interact in the traditional way.

The ReticlePointer position would be a popular interaction method in VR apps.

  • Edit "Place Target With Mouse"

  • Modify the relevant code in update: replace Input.mousePosition with qwr.QwrPointerManager.Pointer.GetScreenPosition()

  • Play the scene and left-click, the target logo no longer appears where the mouse clicks, instead, it appears in the ReticlePointer position.

8. UI Interaction

One can easily find that the UI displays abnormal.

  • Replace EventSystem with QwrEventSystem. (Assets/QWR/Prefabs/QwrEventSystem)

Replace EventSystem directly with QwrEventSystem as needed, or replace the StandaloneInputModule component under EventSystem with QwrStandaloneInputModule. Either way is OK.

i. Replace EventSystem

ii. Replace StandaloneInputModule component under EventSystem with QwrStandaloneInputModule

  • Modify the prompt "Click to set target"

i. Move the "UI" to QwrCameraRig/TrackingSpace/CenterEyeAnchor as a child of CenterEyeAnchor.

ii. Modify UI properties

Change the Canvas Render Mode to World Space. VR needs to be in 3D space.

Modify Rect Transform to display it in the visible range.

Cancel the GraphicRaycaster, because the prompt does not need a collider.

iii. Modify Menu UI

Open MenuUI (Assets/SampleScenes/Menu/Prefabs/MenuUI)

Modify Rect Transform.

Change the Canvas Render Mode to World Space.

9. Build and run on VR device

Click "Build And Run", make sure the Android platform is selected.

At this point, the porting of the VR app is done.

Last updated