Loot.game SDK

Unity SDK

Loot.game is an innovative solution to help Video Game studios monetizing their games and assets.

Introduction

The Unity SDK allows you to fully integrate Loot.game services in your Desktop, Mobile or Web game. Once installed and setup it offers your gamers to synchronized their loot.game account with your game.

You will now be able to receive events from the loot.game platform regarding the connected gamer, and you will also be able to send some event to loot.game

For example : if the user acquired one of your extension on Loot.game, you’ll be able to activate it instantaneously in your game.

You will need:

Please refer to the Getting started section, if you don’t know what it is.

Download the package

You have to download the latest version at the following URL :

https://pkg.loot.game/sdk/lootgame-unity-latest.zip

Import the package

Import the package in Unity using menu : Assets/Import Package/Custom Package…

Once imported a new LootGame folder will be created in your Plugins folder.

Configure the SDK

You have now to insert your embed key in your configuration using the Config Wizard accessible from the menu : Window/LootSDK/Config Wizard

A window will appear letting you type your key You can find how to get your key : HERE

Note : The events tester section lets you simulate an incoming event. Simply give an item ID and click the Send button to observe that your code is working as expected.

Initialize the SDK

On top of your MonoBehaviour script indicate using the LootSDK namespace;

using LootSDK;

In the start method, youn can now initialize the SDK

void Start(){
    Loot.Init(true); //Initialising the Loot.Game SDK, the boolean parameter is for enabling/disabling the Debug.Log returns of the plugin.
}

Allow users to authenticate

You have to allow your users to identify themselves with their Loot.game accounts.

Checking the user’s state

You can check that the user is already SignedIn in the update method of your MonoBehaviour and update your GUI accordingly

void Update(){
    //Display the SignIn Button if the user is not already signed in
    if(Loot.IsInitialized()){
        if(!Loot.IsSignedIn()) //The user is not signedIn{
            // Display the SignIn Button
            // ... 
        }
    }
}

Note : don’t forget to check that the Loot SDK is well initialized before testing the user state.

In this example, if the user is not signedin, we display a simple button to launch the ShowSigninUI method

Offering the user to signIn

simply show the Signin window

Loot.ShowSigninUI(); //Display the Signin Window

It will display a window like this one

Once identified, the user account will be synced. Even after restarting the game. You can offer him to signOut.

Offering the user to signOut

simply launch the signOut Method

Loot.Signout(); //SignOut the user

Listen to incoming events

If the user account is synced, your game will now be able to receive some events coming from the Loot.game platform.

You have several types of events you can attach to :

Type Event name Description
item Acquired OnItemAcquired This event is occuring when the user acquired a new item
Other events coming soon.

How to listen to an event

void Start(){
    //...
    Loot.Init(); //Initialising the Loot.Game SDK
    Loot.OnItemAcquired += OnItemAcquired; //Attach a function to this event.
}

//Occurs when an event is received from the Loot.game infra
private void OnItemAcquired(string eventUid, Loot.Item item, string dateTime){
    switch(item.id){
        case "abcdefgh-1234-1234-1234-123456789": //Do some stuff for a particular item
            //...
            break;
        case "ijklmnop-5678-5678-5678-567891234":  //Do some other stuff for another item
            //...
            break;
    }
}

Some Examples

You will find some examples in the Examples folder of the plugin. Load the scene of your choice and check how things were done.