No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets add UUID generation and persistence Jun 27, 2018
ProjectSettings add UUID generation and persistence Jun 27, 2018
.gitignore Generalize ignored files Jan 10, 2017
README.md add UUID generation and persistence Jun 27, 2018

README.md

BuffPanel Unity SDK

This repository contains an implementation with a simple interface designed to easily communicate with the REST API of the BuffPanel service from within your Unity Game.

Also included is a test project for debugging purposes, which was created in the Unity Framework version 5.4.2f2.

For more information on the BuffPanel service, please visit our website, and read our help pages.

Integration guide

To install the Unity SDK in your game you need to:

  1. Download / clone the newest version of the SDK from this repository.
  2. Copy the contents of the /Assets/Scripts/BuffPanelSDK/ directory from within the repository into your game project.

Setup tracking

Include the following line of code into your project's code. It should be executed at the startup of the game, once per game session for tracking to work correctly.

BuffPanel.BuffPanel.Track(game_token, is_existing_player, attributes, [callback]);
  • game_token is a string value, that's generated by the BuffPanel platform during the registration process and is used to identify your game.
  • is_existing_player is a boolean value, that lets us know whether the current player has already run the game before (true) or is a new player (false).
  • attributes are a Dictionary<string, string> value, that carry any additional information valuable for you, for example purchased DLC list
  • callback is an optional BuffPanel.Callback function to be called after the tracking event is delivered

Former player_token is no longer used, instead universally unique identifier (UUID) is generated and persisted on player's machine implictly.

How it works?

When the Track method is called, the SDK sends an HTTP request to the REST API of the BuffPanel servers.

Upon recieving this event the BuffPanel service identifies your game using the submitted game_token and internally attempts to attribute the player's run event to any of the running campaigns for your game.

Tracking Downloadable Content (DLC)

To track information about the DLC a player purchased in the past we use the attributes parameter. The tracking call's structure allows for tracking of either Steam DLC or any other DLC purchase as long as two information are passed to BuffPanel SDK:

  • a unique DLC identifier for each DLC purchase
  • UNIX timestamp of each DLC purchase

Steam DLC purchase tracking

To acquire the needed information from Steamworks SDK you can:

  1. Get the total DLC count for the player
  2. Iterate through all purchased DLC, listing the entries in the attributes parameter format as
{ "dlc_<appId>": "<purchaseTimestamp>" }
  1. Fill in the DLC purchase UNIX timestamp for all the items
  2. Track a run using the method containing these pair values in attributes parameter
BuffPanel.BuffPanel.Track(game_token, is_existing_player, attributes, [callback]);

Example call:

BuffPanel.BuffPanel.Track(
  "tetris_ultimate_4000", // buffpanel game token
  true, // whether this is an existing player
  new Dictionary<string, string>() {
    { "dlc_657540", "1506599038" },
    { "dlc_643660", "1511176765" },
    { "dlc_907480", 1511076765.ToString() }
  } // "attributes" containing the DLC tracking information
);

Tracking DLC purchase from another store

To integrate other stores and distribution platforms you use, please contact us at contact-us@buffpanel.com.

Callbacks

You can add an optional event handler by extending the supplied BuffPanel.Callback interface and implementing both its methods.

If a request attempt succeeds, the method void success(WWW www) is called and if it fails the method void error(WWW www) is called instead. In both methods the WWW www object contains all relevant information regarding the request. For more information on the WWW class please read the Unity documentation.

To use your extended version of the BuffPanel.Callback interface (let's say you called it MyCallback), you need to include this line of code in the place in your project's code, where you wish to track the event:

BuffPanel.BuffPanel.Track(game_token, is_existing_player, attributes, new MyCallback());