x


Cannot initialise Kong API

Im trying to use the Kongregate API but I can't get it working. I have uploaded the unity3d package to Kong (and of course used another script to display the results from this script) but I cannot get it to work. It just says its not connected. Please help! (What I really want is a working out of the box example package. Then I can modify the example.) Also please make your scripts in JavaScript because I actually understand that. This is my code:

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

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

  // Split the user info up into tokens
  var params = userInfoString.Split("|"[0]);
  userId = parseInt(params[0]);
  username = params[1];
  gameAuthToken = params[2];

}

function Awake(){
        // Begin the API loading process if it is available
        Application.ExternalEval(
            "if(typeof(kongregateUnitySupport) != 'undefined'){" +
            " kongregateUnitySupport.initAPI('MyUnityObject', 'OnKongregateAPILoaded');" +
            "};"
        );

}

function OnGUI(){
    GUI.Box(Rect(0,0,100,20),isKongregate.ToString());
}

Thankyou!

more ▼

asked Jan 12 '11 at 08:09 AM

YoshieMaster gravatar image

YoshieMaster
200 11 11 15

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

http://answers.unity3d.com/questions/35434/unity-kongregate-api-problem

Resolved.

In this line:
kongregateUnitySupport.initAPI('MyUnityObject', 'OnKongregateAPILoaded');

MyUnityObject is the name of object on UNITY, so you need to create a object called MyUnityObject and attach the script on it.

more ▼

answered Jan 14 '11 at 10:39 AM

Borgo gravatar image

Borgo
998 9 13 25

(comments are locked)
10|3000 characters needed characters left

Hi,

You have used the same example as me?

http://answers.unity3d.com/questions/35434/unity-kongregate-api-problem

I'm trying to resolve this too. Just follow my question and vote it up, you don't need to post the same question. I'm thinking about to start a bounty for my question.

I sent a email to Kongregate support too.

Good look!!

more ▼

answered Jan 13 '11 at 06:02 PM

Borgo gravatar image

Borgo
998 9 13 25

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3465
x85
x42
x24

asked: Jan 12 '11 at 08:09 AM

Seen: 725 times

Last Updated: Jan 12 '11 at 08:09 AM