Sign in

SCILLManager

class SCILLManager : MonoBehaviour

Overview

This class is designed as a “Singleton” and uses DontDestroyOnLoad to make sure, that the class instance persists even after scene changes. It provides access to the SCILL SDK APIs and provides some convenience functions to make it easier to work with SCILL from your own code.

Create an empty GameObject in your Scene and add this script. Then provide your API key, AppId and for testing purposes you can also set the User id. Please see the API Reference for more info on this topics.

You can also choose an environment: You should leave that in Production. Sometimes, when working closely with our development team we might ask you to choose a different value but usually Production is the correct setting.

Production:

In production, you should not use this class by providing your API key! Instead you should override this class and override these functions:

  • GenerateAccessToken
  • GetUserId

Inspector Properties

APIKey

Set your API-Key in the inspector. This is for testing purposes. In production, you should implement a simple backend function to generate an access token for your user id.

public string APIKey;

AppId

This is the App id which you can find in the Admin Panel for your app.

public string AppId;

UserId

Set a User ID which is used for testing. In your game you will need to set a persistent user id that will reliably identify the user over time. If you are building a Steam game this could be the Steam-ID for example.

public string UserId;

Environment

Leave in Production if you did not hear anything else from our development team.

public string Environment;

Properties

Instance

As this class is designed as a singleton you can use this getter to get a reference to the instance. It allows you to access the SCILLManager from everywhere in your code.

public static SCILLManager Instance { get; private set; }

Methods

GenerateAccessToken

public virtual string GenerateAccessToken(string userId)

This class uses the SCILLBackend class to call the GenerateAccessToken function to directly call SCILL backend with the API key provided in the inspector. This is not recommend in production and you should override this function to call a backend function you control to hide the API key from the user.

Parameters

userId string

The userId for which the access token should be generated.

Returns

Returns the access token as a string which is stored and reused for all further requests to the SCILL backend.

GetUserId

public virtual string GetUserId()

This class just returns the user id provided in the inspector. This is good to quickly test with one persistent user that you control. In production you need to override this function to return your own User ID depending on your game.

Returns

Returns the User ID which is then used in a call to GenerateAccessToken to generate the access token.

SendEventAsync

public async void SendEventAsync(string eventName, string eventType = "single", EventMetaData metaData = null)
Parameters

user_id string

This is your user id. You can set this to whatever you like, either your real user id or an obfuscated user id. However you need to be consistent here. Events linked to this user id only track if challenges or battle passes are unlocked with the same user id.

session_id string

This is required if event_type is single and identifies a session. This can be anything used to group events together. For example this can be a level or a match id.

event_name string

This is the event type as a string. These have predefined event names for many games and applications. It’s wise to use those as this allows us to analyse data and help you balancing your application or game.

event_type string

This is either single or group. You can send multiple events in one request (group) or send events in sequence. Please note, that depending on your tier you might run into rate limits.

meta_data EventMetaData

A EventMetaData object that you can/must use to set property values for the respective event.

Returns

In case of a success, this function returns an instance of ActionResponse. In case of a failure, this function returns an error.