# Unity Platform SDK

# Prerequisites

Define your app in the Developer Center before get started. You will get an App Id to initialize the SDK. You can find more details from here

Platform SDK is a toolkit to enable your APPs to integrate with Pimax Store, you need to integrate with OpenVR to render your game in VR environment.

# SDK Introduction

This documentation guides you to develop VR APPs that run on Pimax headsets with Pimax Unity Platform SDK (hereafter called SDK) in Unity. Functions provided by the SDK include DRM and users' information. Functions such as achievements, in-app payments, and DLC will be supported in the future. The SDK is provided in the format of UnityPackage. You will see the following directories after importing.

image2022-4-26_11-40-25.png

Folder Introduction
Platform\Editor Scripts related to Unity Editor.
Platform\Prefabs Preset objects.
Platform\Plugins Dependent files.
Platform\Samples Samples.
Platform\Scripts Main scripts.
Resources Configuration files.

# Tools

Find useful development tools under Tools folder.

# Mock entitlement result

test.json is here only for debug purpose. You can copy this file to your work directory to mock the entitlement result and other platform features during development, MAKE SURE to remove it while uploading APPs to Pimax Store.

When running in edit mode, put this file into your project path to be at the same level as the Assets folder. When running after building, put this file in the same path as the executable file.

Note: The service will read the content of test.json only when the appSecret is correct. The appSecret needs to be obtained from Developer Center, you could find more details here: test.json.

{  
    "appSecret": "TESTSECRET", //appSecret of your app, Please remove comments when using
    "Entitlement": 1001,  //Result of CheckEntitlement(). Please remove comments when using 
    "LoggedInUser": {
        "username": "json",
        "userid": 123456  
    }    //Result of GetLoggedInUser().  Please remove comments when using
}

You can modify test.json under your work directory and restart to test different results.

# PiPlatformService

Start Pimax Store to communicate with your app. If your app has not been released yet, you can use test.json for simulating development. The specific usage process is shown above.

# Instructions for SDK configuration

# Development environment requirements

Windows:

  1. Unity 5.6.6 or above
  2. Pimax Client 1.3.0.17 or above
  3. 64bit architecture is recommended.

Android:

  1. OS version 0614 or later

# Quick Start

# Step 1: Create a new project

Open Unity and create a new project as shown:

image2022-2-15_18-41-20.png

# Step 2: Import SDK

Enter Assets - Import Package - CustomPackage.

worddav2f2873a3001710893c9fa33df49c2858.png In the pop-up window, click to open PimaxPlatform.unitypackage file :

image2022-2-15_18-43-8.png

# Step 3: Setup AppID

image2022-2-10_17-37-10.png

In the pop-up window, input an AppID and click Apply, or click Ignore and close it. You can open it again from ToolBar - Pimax - PlatformSettings.

# Step 4: Run the sample

There is a simple example in Pimax/Platform/Samples/SimpleExample. Double click the SimpleScene to load it.

image2022-2-10_18-1-26.png

Final preparations before running as below, if you use the PimaxClient, ignore this step.

Copy test.json from Tools to the root of your work directory.

Then you can explore the SimpleExample.

image2022-4-26_12-34-5.png

Awake()  will be called by Unity when the script starts. It will initialize the PiPlatformService and SDK.

Start()  will check the entitlement first and then try to get some infomation.

These requests are asnyc functions, and the result will be returned by callback functions which are sent as parameters.

CheckEntitlement:

It will return the current network connection and whether the current user possess this game, we recommend that you quit game if the user does not have this game

image2022-4-26_12-42-10.png

These callback functions are process actions to the infomation.

Notify_LogOut will be received if user logouts PimaxClient, you probably want to quit the game now.

Notify_RunningError is some other errors, for example, if too many devices launch this game.

Click play on the top of Unity.

If no error occurred, you will see:

image2022-4-24_11-49-39.png

# Add SDK To Your Project

Import the SDK following the instructions above

Find prefab PvrManager in the  Pimax\Platform\Prefabs

Put it into your first sence

image2022-4-26_12-54-42.png

When you call the interface of the SDK, attach the callback function as a parameter.

In order to receive messages actively sent by PiPlatformService, please subscribe to the events in the following figure.

Subscribe with code or use the inspector as you like.

image2022-4-26_13-1-57.png

# Set up for the Android platform

If your game needs to run on an Android all-in-one console, perform the following settings:

  1. Open the Player tab in Project Settings

  2. Find the Scripting Backend item in the Android platform settings below, set it to IL2CPP

# Mock entitlement result

You could mock entitlement result just like PC platform except that you should put the test.json to the follow location:

/data/local/tmp/{$your_app_id}/test.json