# Unity PC XR SDK
# Environment building
# Installation of Pitool
Find PiTool download link from here or Pimax official website (opens new window).
# Connecting Pimax Helmet Equipments
Connect the power adapter data line, DP and USB cable to the computer, turn on Pitool and wait for the device to connect to the computer. When the helmet shows the green light, the connection is successful.
# Use of Unity
# Download Unity Development Engine
Google Search Unity, Download Unity Engine from Unity Official Website.
# Create Unity projects
Double-click Unity to open the desktop, create a new project, and click NEW in the upper right corner to create the project.
After clicking, an option window appears. The first line of project name is the project name, and the second line of location is the path to store the project. After entering the completed project name and path, click Create Project to create a Unity project.
When the creation is complete, a Unity operation window will be entered, which is our Unity project.
# Import SDK
# Download/Install SDK
Download Pimax Unreal sdk from here and install the sdk. The Unity_SDK is installed to \Pimax\Sdk\Unity_plugin by default.
# Import SDK
- Find the Unity_plugin folder and import the PVR-Unity.unitypackage resource package into the scenario. There are two ways to import the PVR-Unity.unitypackage resource package into the scenario：
Method 1 : Drag and drop the PVR-Unity.unitypackage resource package onto the Assets folder as shown in the figure below：
Method 2 : Find the ASSETS file directory in the figure. Mouse over to Assets and right-click Custom Package in Import Package. Find the folder that holds the PVR-Unity.Unitypackage resource package in the selection box that appears. After clicking the PVR-Unity.Unitypackage in the folder, click the "Open" button in the lower right corner.
To complete one of the above two operations, a bullet window will appear as shown in the figure. Click the Import button in the lower right corner to import the SDk.
The following directory of resource files shows that we imported successfully.
# Use of SDK
Find the PVRUnity folder in the Asset directory, drag the PVRCameraRig and PVRSSession prefabricates in the Prefab folder into the Sence view, and delete the MainCamera of the original scene, as shown in the figure：
To ensure that the helmet in Pitool is connected successfully, we can start our VR development journey by clicking the left triangle button of the red circle in the picture to run the project.
# Pack Unity
How to package VRDisplayDemo into. EXE file?
Step 1: Click Save Sence in the File column in the upper left corner to save the scene
Step 2: Click File - > Build Setting in the top corner and an option box appears，
Step 3: Click add OpenSences to add your packaged scenario VRDisplayDemo， Choose the published platform as the first one in the option bar（PC-side options in red boxes）， Select the Architecture as x86_64 (click on the x86 bar button to display a drop-down menu, and select X86_64)
Step 4: After the above two steps are completed, click the Build button in the lower right corner (as shown below), and a window will appear to select the path to store. exe. After selecting the path you want to store, click Save. In this way, a Unity version of the VR project has been successfully completed.
# Realization of Helmet Key Function
# Response to keystroke events
Find the PVRInputEvent. CS script in the SRC folder of the PVRUnity under the Asset directory, right-click in the blank of the Hierarchy panel to create Creat Empty, click the GameObject, and drag the script to the location shown in the figure：
Create a script, right-click Creat - > C Script in the red space below, create a script, double-click to enter:
The script inherits the PVR.Unity.IPVRInputEventTarget and adds the following code in the script, and changes the output print log to the relevant logic code to realize the press-up event response of the key:
4 .In the event.format of the RecenterTest.cs script in the Sample directory, the default buttons:
# Reset the positive direction
The interface can be invoked in the key response to achieve a positive reset, as shown below:
# Meaning of each interface script
Realize the connection with PVR runtime, each scenario needs and only needs to add one, you can use PVRSession. prefab to add
Realize the binding of GameObject's pose (direction and position) to head, handle, etc. When the PVRCamereRig sub-object is checked out, the script in PVRCamera can turn off the gyroscope on the VR headgear, as shown in the figure：
Position the eyes according to their position
Implementing the output of camera screen to helmet, depending on Camera component, PVREyeOffset component.
Achieve the sending of key events on the handle, and use the format in RecenterTest. CS script to receive events, complete the response of keys, and control keys。
# Introduction to sample scenarios
Example VR example of a single PVRCameraRig
The example uses multiple PVRCameraRigs to implement more complex requirements, including whether each PVRCameraRig can be customized with head control.
In the example scenario, an object has head or handle action control.
Example Handle Button Event Processing and Resetting Positive Direction.
The example shows different windows pictures from those in the helmet by ordinary camera.