- Home /
How To Build A Leaderboard Using Unity 3.5 Beta
Unity 3.5 Beta is a fantastic gift this Holiday Season! There are so many levels and components to Unity one can barely become proficient before exciting new featurs are added. On that note, I'm using 3.5B to build an IOS game that requires a leaderboard. Through a post on the Forum I was able to find the Social API in the Documents directory. I created a Javascript named Authenticate and pasted the following Social API code. I got this error: (7,12): BCE0019: 'Authenticate' is not a member of 'UnityEngine.Social'.
function Start ()
{
// Authenticate and register a ProcessAuthentication callback
// This call needs to be made before we can proceed to other calls in the Social API
Social.Authenticate( ProcessAuthentication );
}
// This function gets called when Authenticate completes
// Note that if the operation is successful, Social.localUser will contain data from the server.
function ProcessAuthentication( success: boolean)
{
if (success)
{
Debug.Log("Authenticated, checking achievements");
// Request loaded achievements, and register a callback for processing them
Social.LoadAchievements(ProcessLoadedAchievements);
}
else
Debug.Log("Failed to authenticate");
}
// This function gets called when the LoadAchievement call completes
function ProcessLoadedAchievements(cache: Achievement[])
{
if (cache.Length == 0)
Debug.Log("Error: no achievements found");
else
Debug.Log("Got " + cache.Length + " achievements");
}
I have no idea what to do with the API, if it had loaded, but I know it's not good to start off getting errors right off the bat. I created an empty game object I had planned to attach the script to but the error killed that approach deader than a door knob. My question then, is can someone give us(the forum showed more 3.5 users with GameCenter questions) a step by step on how to build a simple basic GameCenter Leaderboard using the Social API? I've setup 'GameCenter' in iTunes Connect. Have loaded the GameCenter Framework in Xcode. Read documentations. I'm all dressed up and ready to go! Help!
Answer by DA_ATeam · Jan 14, 2012 at 11:43 PM
Oooook! I added a little Pixie Dust to my cinnamon oatmeal this morn, and BAM! Game Center pops up on the development build on my iPad! Now I get a a Game Center box message asking me to sign in. After signing in, I get an error message saying 'This game is not recognized by Game Center. I imagine this is because I haven't enabled Game Center in iTunes Connect yet. Excuse me a moment while I 'Tebow' So, here's the drill for others who've never attempted this amazing feat at home.
1. Create a new Javascript in Unity. I named it Game Center **2.**Copy and Paste the Social API code into your new Game Center script. 3. Edit your code; changing 'Social.Authenticate', to 'Social.Default.Authenticate' 4.In a new scene, or an appropriate scene, create an empty game object and add the script 'Game Center'. (I added 'Game Center' script to my existing Total Points scene. 5. Go into Xcode and add the Game Kit framework to your project. Very Important Step! 6. Go to you Project in Xcode >Click on Target > Build Phases > Click on the '+' sign and add the Game Kit. (on the far right side of this line I changed 'optional' to 'required' Don't know if that's mandatory or not). 7.Connect your iPad or iPhone 8.* Back in Unity 3.5 Beta, Hit build and run! Game Center sign in box should appear.
If you don't know! Now you Know. Brother!
This worked for me, although I did not have to do steps 3, 5 or 6.
Thank you very much this is extraordinarily helpful! In unity 5 replace Social.Authenticate to Social.localUser.Authenticate
Answer by pepefirst · Apr 19, 2012 at 03:49 PM
This is the best description I ever have seen on how to implement Game Center on Unity. You go step by step on it. Thanks for your help!
Your answer
Follow this Question
Related Questions
GameCenter Leaderboar and Achievements at Once... 2 Answers
Social.ShowAchievementsUI() not showing achievements 1 Answer
iOS Game Center Achievements Not Working 1 Answer
Achievements and Leaderboard for Unity Windows 10 games 1 Answer
Google Play Services leaderboard takes time to appear 0 Answers