A pure code implementation of the Kongregate statistics API for Unity as a single C# file. The statistics API is used for counting items (such as level completions, enemies killed, high score, etc) on Kongregate games. Games implementing the API also get a bigger share of ad revenue from the website, where eligible.
- Copy the KongregateAPI.cs file to your Unity project's "Scripts" folder
- Anywhere in your code (e.g. your
Maingame class), create an instance of the KongregateAPI:
KongregateAPI kongregate = KongregateAPI.Create();
- Whenever you need to submit statistics, do:
kongregate.SubmitStats("high-score", 1000); kongregate.SubmitStats("tanks-destroyed", 1);
Create()(Static): creates a
KongregateAPIinstance and returns it (automatically creating a
GameObjectfor itself so it can receive events).
SubmitStats(string name, int value): submit statistics to the Kongregate API.
isConnected: returns whether the user is properly connected to the Kongregate site API. Read-only.
userId: id of the current user. Read-only.
userName: name of the current user. Read-only.
gameAuthToken: game authorization token. Read-only.
In general, you don't need to do anything special for your code to work on Kongregate. Just implement the above code and you're good.
Notice, however, that:
- Testing on the pre-publish screen won't work either (the
kongregateobject is not instantiated). The API only works after your game is properly published.
- If you want to make sure your game is working with the API, go to its published page, add
- This implementation doesn't support callbacks.