API Integration with unity games

8 posts

Flag Post

I don’t understand how to integrate the kongregate api into a unity game, there is no unity specific documentation that i can find. Do i have to download a file, or load it in an assetbuldle. Can anyone help me.

 
Flag Post

You’ll need to read up on the Javascript API which is currently used to talk to Unity.

 
Flag Post

That doesn’t help me.

 
Flag Post

Maybe read up on the old documentation if you don’t like the new one:

http://www.kongregate.com/developer_center/docs/zh/using-the-api-with-unity3d

 
Flag Post

thank you, this helped me

 
Flag Post

It doesn’t seem to work for me, could you show me some example code? This gives false with ‘kamera’ being the Main Camera that has the script.

 
Flag Post

sry, here is the bad code: #pragma strict

var isKongregate = false;
var userId = 0;
var username = “Guest”;
var gameAuthToken = "";

function OnKongregateAPILoaded(userInfoString){
// We now know we’re on Kongregate
isKongregate = true;

// Split the user info up into tokens /*var params = userInfoString.Split(“|”0); userId = parseInt(params0); username = params1; gameAuthToken = params2;*/

}

function Start () {
Application.ExternalEval(
“if(typeof(kongregateUnitySupport) != ‘undefined’){” +
" kongregateUnitySupport.initAPI(‘kamera’, ‘OnKongregateAPILoaded’);" +
“};”
);

}

function Update () {
//print(is
print(isKongregate);
}

 
Flag Post

Are you using an iFrame game or just directly uploading your game to Kongregate?
Either way, the API isn’t being loaded because onKongregateAPILoaded is not being called.

  • If it is an iFrame game, then you’ll need to look at the Javascript API to load the API on the webpage which your Unity code will interact with.
  • If it is a direct upload, then perhaps Start() isn’t being called or an error is being thrown somewhere.