I want to integrate into my game some sort of leaderboard. I want it to be compatible with all platforms. I have researched and found that the Social API provided by Unity is a good choice, but there is not that much documentation on it and there are no tutorials on it. http://docs.unity3d.com/Documentation/ScriptReference/Social.html Has anybody worked with it? Does anyone know of any tutorials out there about it? Thanks.
I use it all the time, works great. Make a call to Social.localUser.Authenticate() initially, then call Social.ReportScore() whenever you want to submit a score. It's really that simple, what part specifically was confusing you?
No, Unity Social's API is a wrapper around... something. On iOS, the "something" is GameCenter. Its goal is to provide you an unified interface toward all the GameCenter, GooglePlay, etc. that each have their own API.
Thank you for the replies... I wanted to display the leaderboard in my game somewhere. Is there a tutorial on how to implement that? I know there is ShowLeaderboardUI but just calling that method can't be all.
It's not a Unity Social API, as I'm not aware of it. But I can recommend you a Google Play Service lib. Here is a link on how to start: 1. https://developers.google.com/games/services/console/enabling and here is a link for direct github project: https://github.com/playgameservices/play-games-plugin-for-unity or https://developers.google.com/games/services/integration/ (for other engines). It will give you sign in unlock/reveal/increment achievement post score to leaderboard cloud save read/write show built-in achievement/leaderboards UI turn-based multiplayer (new) real-time multiplayer (new) For both iOS and Android... and by the way the Plugin is managed by Google itself, so it's pretty good.
_Daniel_, I was hoping you could share some more information about the Social API since you said you're familiar with it. Like the OP, I've been hunting around for examples but have found none. More than examples, I'd like a good explanation of how this is supposed to work. I have a Unity project currently. I haven't published it to any of the stores. I intend to publish it to Apple, Android and Windows stores eventually. On start, I try to authenticate current user. That is successful (in Unity). I create a leaderboard and load scores. Unity gives me some default 4 scores. When my game is finished, I post my score using Social.ReportScore() . I get a success here. Should I expect to see my saved score when I run my game again? I don't. I'm guessing that's because this is running in Unity and I'm seeing Unity's default "social manager". When I connect to the app stores, will this just magically work? When I try to call Social.ShowLeaderboardUI(), I get a not implemented error. Is this something that will also magically work when I connect it to the app stores? Or is this something I need to implement on my end? This all seems very powerful, but to a newbie like me, it's hard to understand what is expected.
Code (CSharp): using UnityEngine; public class SocialAPI : MonoBehaviour { void Start () { if (!Social.localUser.authenticated) Social.localUser.Authenticate (success => { //do something on success if you like }); } public void ShowLeaderboard () { if (Social.localUser.authenticated) Social.ShowLeaderboardUI (); } public void ReportScoreToLeaderboard () { if (Social.localUser.authenticated) { Social.ReportScore ("integer data to be sent", leaderboardID, success => { if (success) Social.ShowLeaderboardUI (); }); } } } I tested this code on iOS. You need to set your leaderboards in iTuneConnect first. Then attach this script to a gameobject in your scene and then call those two public methods whenever you need to show or report to leaderboard.