- Home /
Unity Kongregate API Problem
Hi, I need some help.
I'm having problem implementing the Kongregate API.
I have Used this little script:
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()); }
- I upload the .unity3d to kongregate
- If I use a externalEval with "alert(typeof(kongregateUnitySupport))", it will alert "Object". It means that the object exists.
- The Script calls the initAPI function of this script but doesn't call back the OnKongregateAPILoaded function.
- The GUI.Box ever show the message "False" what is to be modified when the function is called.
I have used this example: http://answers.unity3d.com/questions/33227/how-do-i-implement-the-kongregate-api But doesn't works.
The Kongregate.Package in the Unity.com page have the some problem to me.
please, help me.
Thanks, William Borgo
Do I need to upload any other file (script) when uploading my game?
Answer by Ehren · Jan 13, 2011 at 10:37 PM
Is the name of the object the script is attached to 'MyUnityObject'? If not, the callback to OnKongregateAPILoaded will fail.
Another possibility: if you're doing other ExternalEvals that happen to result in javascript errors, subsequent ExternalEval calls will not work.
Yes!!! It's work. I didn't think that was about the game object. I did think that is about the object of the website.
Answer by 3v3rton · Jan 13, 2011 at 12:59 PM
This looks like a problem with Kongregate Scripts, however they have some games that are able to connect with API.
I sugest you to contact Kongregate support. Maybe they can help you.
Ok, I have send this question to kongregate's technical support. The only problem is it can take 5 days for them to respond.
Answer by psychicparrot · Feb 06, 2011 at 04:24 AM
If you didn't solve it yet, the following fix worked for me (yippeee) after nothing else did!
Enjoy!