# 5. Samples

# 5.1 Import Samples

img

Fig 5.1 Import Samples

# 5.2 Sample Scenes

SDK Samples package provides sample scenes for developers for common VR-specific features such as XR ActionBased, XR DeviceBased, character controller, the acquisition of user account of QIYU device.

# 5.2.1 Boundary

In Sample, BoundaryTest scene provides the API to test, includes the visibility and the point set of boundary, and the interaction of boundary.

There are four buttons in the Demo:

No. Button Description
1 GoMainScene Go to Main scene
2 Visible Set boundary visible
3 InVisible Set boundary invisible
4 CreateGeometry Get geometry point set

Overlay shows the real-time data of right controller(you could change to left hand):

No. Tag Description
1 isTriggering Whether trigger the boundary
2 ClosestDistance The closest distance of Boundary
3 ClosestPoint The closest Point of boundary
4 ClosestNormal The closest normal line
5 GetConfigured Whether define the boundary
6 GetVisible True: visible. Flase: invisible
7 getDimensions Get dimension of boundary
8 getFloorLevel Unity XR API

Please refer to 4.2 Boundary API: https://dev-qiyu.iqiyi.com/doc/develop/unity/unityxr/reference.html#_4-2-boundary-apis

# 5.2.2 QIYU Controller

In ButtonTest.cs, we use official UnityXR APIs to realize the controller related information, including the call of APIs such as device velocity, device acceleration and buttons:

HMD information:

No. Tag Description
1 isValid Whether is valid
2 name Name
3 serialNumber it is not supported at the moment
4 manufacturer Device manufacturer
5 characteristics Character name
6 devicePosition The position of device
7 deviceRotation The rotation of device
8 refreshRate Refresh rate

Controller information:

No. Tag Description
1 isValid whether enable or not
2 name name
3 serialNumber it is not supported at the moment
4 manufacturer Device manufacturer
5 characteristics Character name
6 batteryLevel Battery level
7 devicePosition The position of controller
8 deviceRotation The rotation of controller
9 refreshRate refresh rate
10 deviceVelocity The velocity of controller
11 deviceAngularVelocity The angular velocity of controller
12 deviceAcceleration The acceleration of controller
13 deviceAngularAcceleration The angular acceleration of controller
14 grip The strength of grip button
15 gripButton Whether the grip button is pressed or not
16 menuButton Menu button
17 primary2DAxis The position of joystick
18 primary2DAxisClick Whether press the joystick or not
19 primary2DAxisTouch Whether the finger on joystick or not
20 primaryButton X/A button
21 primaryTouch Whether the finger on buttons or not
22 secondaryButton Y/B button
23 secondaryTouch Whether the finger on buttons or not
24 trigger The strength of pressing trigger button
25 triggerButton Whether pressing trigger button or not
26 triggerTouch whether the finger on trigger button

Please refer to Unity XR InputDevice: https://docs.unity3d.com/ScriptReference/XR.InputDevice.html (opens new window)

# 5.2.3 Keyboard

In Keyboard sample, we provide Sogou inputs method, and visible and invisible input box:

# 5.2.4 QIYU Overlay

The example scene of QiyuOverlay shows how to use Overlay and Underlay to synthesize the composite layer with high quality. For detailed information about the settings of the composite layer, please refer to QIYUCompositorLayer.

When loading the sample scene, you can see multiple layer renderings in front of the camera, including overlay, underlay, OES and Default rendering results.

# 5.2.4.1 Scripts

We provide Earth.cs and OESHelper.cs for developers to refer to the earth rotation and OES texture. In addition, QiyuOverlay file provides an example about how to set in inspector.

# 5.2.4.2 Main Function

The QiyuOverlay provides multiple type and shape composite layer sample.

Fig5.2.4.2.1 Qiyu Overlay sample scene

Is External Surface Demo, please refer to Underlay-oes layer and OESHelp script.

Fig5.2.4.2.2 OES Layer sample

# 5.3 Sample Scripts

  • QiyuScreenFade.cs

Sometimes the screen may flash white due to a sudden change in the camera rendering during the on-off screen or scene switching.This script provides the FadeIn effect to solve this issue. Please hang the script on the Main Camera if needed.

img

Fig 5.2 ScreenFade.cs

# 5.4 Unity XR Official Interaction Samples

Please refer to the XR Samples from Unity, which include joystick movement, para-curve movement, UI clicking and so on. You can find them at https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples (opens new window).