- Home /
Implementing Game Center
I'm developing a mobile game in Unity and would like to implement Game Center to have Leader Boards and Achievements. At the end I leave the code. So far I've managed to authenticate the user, but when I want to add points to the leaderboard it bugs: "Leader Board not found". I have also tried to show the Board with ShowLeaderBoardUi but it says: "ShowLeaderboardUI not implemented". Thank's for your help!
#pragma strict
var points : float = 3000;
function Start () {
Social.localUser.Authenticate (function (success) {
if (success) {
Debug.Log ("Authentication successful");
var userInfo : String = "Username: " + Social.localUser.userName +
"\nUser ID: " + Social.localUser.id +
"\nIsUnderage: " + Social.localUser.underage;
Debug.Log (userInfo);
}
else
Debug.Log ("Authentication failed");
});
Social.ReportScore (points, "europe.footsteps", callback) ;
Social.ShowLeaderboardUI ();
}
function Update () {
}
function callback (){
Debug.Log("Callback");
}
i think prime31 make a plugin, just use that and save weeks
Answer by AlucardJay · Aug 23, 2012 at 04:15 PM
http://docs.unity3d.com/Documentation/ScriptReference/GameCenterPlatform.html
I have found and used a class that is easy to call and start referencing to and from GameCenter with. Just follow the guide, read the Unity Script Reference link on the 'site, and grab the singleton script =]
http://www.crywolfstudios.net/medieval-zombies-blog/2012/5/9/how-to-add-game-center-in-unity3d.html
This uses the information in the API as Mander has given you the link for in his answer.
Also as Fattie stated, check out Prime31, regarding their GameCenter Plugin and StoreKit (In App Purchasing) : http://prime31.com/unity/
But can you report a score from this Game Center Singleton? I don't see anithing from that in the code :(
For this I added a method to the end of that script. Basically a direct copy of Social.ReportScore (make public void) : http://docs.unity3d.com/Documentation/ScriptReference/Social.ReportScore.html?from=ISocialPlatform
http://docs.unity3d.com/Documentation/ScriptReference/GameCenterPlatform.html
O$$anonymous$$! perfecte. But do you know if i can request to this singleton from a javascript, or is necessary to be a c file as the main singleton?
I used it with C#, but if you look at this (point 3.) :
http://docs.unity3d.com/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html
All scripts that are compiled in this step have access to all scripts in the first group ("Standard Assets", "Pro Standard Assets" or "Plugins"). This allows you to let different scripting languages interoperate. For example, if you want to create a Javascript that uses a C# script: place the C# script in the "Standard Assets" folder and the Javascript outside of the "Standard Assets" folder. The Javascript can now reference the C# script directly.
you can use the singleton and call it with JS. As calling the leaderboard and achievements start apple's interface, there is no problem with needing to read information from the C# script. Just put it in Standard Assets or Plugins folder. I used this a while ago, and since then havn't done any dev projects. If you are unsure and want some certainty, search for GameCenter plugins Unity or something similar, even search the asset store. There are a few other products out there that vary in price.
Answer by Mander · Aug 23, 2012 at 02:54 PM
did u check the documentation? i think u can make it work with it. if not heres the link i personaly havent tried it but it looks promising
Your answer
Follow this Question
Related Questions
Object generator? 1 Answer
2 Questions about iOS Pro 1 Answer
How to make an ingame weapon/ammo shop 0 Answers
Making A Tileset 1 Answer