Installing the PDK for Unity3D

This guide is based on a new installation of the PDK. To upgrade from an older version please see the upgrading manual

Set API compatibility to .NET 2.0

First thing you need to do is set the API compatibility to .NET 2.0. With a project open, go to Edit > Project settings > Player. This will open a new screen in the Inspector window. Click on the tab Other Settings to display the Api Compatibility Level option. This is (by default) set to .NET 2.0 Subset. Change this to .NET 2.0 Having trouble finding it? check this image.

Import the Pillo Development Kit

Import the Pillo Development Kit as you would with any third party Unity package. Go to Assets > Import Package > Custom Package and link to the PDK3.1.0.unitypackage that is located in the PilloPDK\lib\UnityPackages folder of the PDK zip. Required for development is everything located in the _Core folder. Additionally you can import the Assets and Examples folders if you wish to get the demo data.

Setting up the project

The fastest way to prepare your project now is to simply drag and drop the prefabs from the prefab folder into your scene. Drop both the PilloController.prefab and the PilloSubscriberExample.prefab into the scene. The PilloController is simply the script that hosts all Pillo functionality with UseEvent enabled by default. In the PilloSubscriberExample you can find the event functions. Here you can start programming your game logic. It also shows how to subscribe and unsubscripe these functions. From here on you can start building your first Pillo game!

Embed in your existing scripts (optional)

Alternatively you can choose to not import the Subscriber example in your scene, but instead use functions or add events to your existing game scripts.

To use the API's methods, use our API Method guide.

To use the Events in your existing scripts, first add the following two functions to the bottom of your script. You only need to Subscribe and Unsubscribe the methods you are going to use, but to be safe, and for testing purposes, it's easier and better to embed all methods.

private void SubscribeMethods()
    {
        PilloController.PilloConnected += OnPilloConnect;
        PilloController.PilloDisconnected += OnPilloDisconnect;
        PilloController.PilloPressed += OnPilloPressed;
        PilloController.PilloDown += OnPilloDown;
        PilloController.PilloReleased += OnPilloReleased;
        PilloController.PilloShaken += OnPilloShaken;
        PilloController.PilloGyro += OnPilloGyro;
    }

    private void UnSubscribeMethods()
    {
        PilloController.PilloConnected -= OnPilloConnect;
        PilloController.PilloDisconnected -= OnPilloDisconnect;
        PilloController.PilloPressed -= OnPilloPressed;
        PilloController.PilloDown -= OnPilloDown;
        PilloController.PilloReleased -= OnPilloReleased;
        PilloController.PilloShaken -= OnPilloShaken;
        PilloController.PilloGyro -= OnPilloGyro;
    }

After that, call the functions on Start and OnDestroy.

void Start()
    {
        //-- subscribe methods to broadcaster --//
        SubscribeMethods();
    }

    void OnDestroy()
    {
        //-- unsubscribe methods from broadcaster upon destruction of this. --//
        UnSubscribeMethods();
    }

After that insert the desired Event methods in your script.