1. Replace the Camera with DpnCameraRig;
2. Replace the mouse position with the pointer position;
3. Replace EventSystem with DpnEventSystem;
4. Change the UI Canvas's Render Mode to World Space and adjust the position.
Take the Unity 5.3.0 sample project (CharacterThirdPersonAI) as an example.
Unity version: Unity 5.3.0 or later
DPVR Unity plugin version: DpvrUnity0.7.6b or later: Click here to download
Develop for E3? Please also install the latest DPVRAssistant.
1. Download related resources
a) Unity 5.3.0 sample project:
2. Install and open the Unity5.3.0 sample project
a) Install the sample project
b) Open the installed project
3. Open the scene CharacterThirdPersonAI (Assets/SampleScenes/Scenes/CharacterThirdPersonAI)
4. Play the scene
Porting VR applications
5. Import DpvrPlugin0.7.6b.unitypackage
The DpvrUnity plugin is based on unity5.3.0. If your version is 5.3.0+, Unity will prompt you to upgrade the API when importing the plugin.
Please select "I Made a Backup. Go Ahead!".
If the upgrade window does not pop up automatically, please close the project and reopen it.
6. Unity settings
a) Follow Unity setting guidance and complete the project setting
b) Find the Game Tab and add the Aspect Label (1024 x 1024). The aspect ratio of a single eye is 1:1
c) According to your DPVR device type, select the appropriate platform and Switch Platform.
For all-in-one (eg. P1/P1 Pro, P2/P2 Lite), please select "Android".
For the E series (eg. E3), please select "PC, Mac & Linux Standalone".
7. Replace Camera with DpnCameraRig (Assets/DPN/Prefabs/DpnCameraRig).
Developer needs to decide whether to replace the Camera object directly, or to use DpnCameraRig as a child object.
In this example, CCTVCamera has many other functional components, so DpnCameraRig is used as a child object.
a) Find CCTVCamera (Main Camera)
i. Modify the location of the Camera
ii. Uncheck Camera related items
b) Use DpnCameraRig as a child of CCTVCamera.
Click the Play button and preview the scene. When previewing in the editor mode, hold down the Alt key, move the mouse around with the right mouse button pressed in Editor window to look around. A ReticlePointer is added to the center of the scene.
8. Replace the touch point of a touchpad, or the location of the mouse with the ReticlePointer position.
Play the scene and left click, a target logo will appear where the mouse clicks, and the character will move to that position.
However, VR apps are different in interaction from traditional desktop or mobile apps.
After wearing the helmet, 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.
a) Edit "Place Target With Mouse"
Modify the relevant code in update: replace Input.mousePosition with dpn.DpnPointerManager.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.
9. UI interaction
One can easily find that the UI displays abnormal.
a) Replace EventSystem with DpnEventSystem. (Assets/DPN/Prefabs/DpnEventSystem)
Replace EventSystem directly with DpnEventSystem as needed, or replace the StandaloneInputModule component under EventSystem with DpnStandaloneInputModule. Either way is OK.
i. Find the default EventSystem
Ii. Replace StandaloneInputModule with DpnStandaloneInputModule
b) Modify the promption "Click to set target"
i. Move the "UI" to DpnCameraRig/TrackingSpace/CenterEyeAncher as a child of CenterEyeAncher.
ii. Modify UI properties
(1) Change the Canvas Render Mode to World Space. VR needs to be in 3D space.
(2) Modify Rect Transform to display it in the visible range
(3) Cancel the GraphicRaycaster, because the promption does not need a collider.
iii. Modify MenuUI
Open MenuUI (Assets/SampleScenes/Menu/Prefabs/MenuUI)
(1) Modify Rect Transform.
(2) Change the Canvas Render Mode to World Space.
10. Compile and run
For all-in-one (eg. P1/P1 Pro, P2/P2 Lite), one can add a 3DOF controller for interaction
Select "Flip" in DPVR Setting
Compile and run
At this point, the porting of the VR app is done.