- Home /
Trying to understand the social class
I'm well aware of prime31's plugins, but I'm trying to learn and would rather implement leaderboards myself (plus save the money). As I'm sure people have stated ad naseum, Unity's Social class is woefully undocumented. It seems very simple overall, but it's just not explained how everything works.
I think I have GameCenter working correctly in my game, but I'm not entirely sure, so I have some questions for anyone who can help. I've read tons of tutorials and such, but none of them are good at explaining in detail.
What exactly is happening when I call Social.localUser.Authenticate()? I thought this was actually pinging Apple's servers to connect to GameCenter, but I've realized that it still authenticates even with no internet connection. Is this just checking that the player is logged into GameCenter (which apparently doesn't require an internet connection)?
What is the purpose of Social.CreateLeaderboard()? If a leaderboard exists on Apple's servers, why am I creating one locally? Is it like a container for the data being pulled from GameCenter? Every tutorial I've seen shows this being done before Social.ShowLeaderboardUI(), and then creating a name (id) for the newly created leaderboard. Do I need to do this just once when starting my game, or do I need to do it again every time I show the leaderboards?
The only things I'm currently using in my implementation of a leaderboard are Social.localUser.Authenticate(), Social.CreateLeaderboard(), Social.ShowLeaderboardUI(), and Social.ReportScore. But there are other things in the Social class that make me think it's more complicated and I'm missing something. Like what about Social.LoadScores() and Social.LoadUsers(). Should I be using those for something?
My understanding is that the Social class is meant to apply to both GameCenter and Google Play Game Services with the same code. But I don't understand how that works when using Social.ReportScore() and I have to list the leaderboard name. If the iOS and Android leaderboard names are different then am I just expected to detect the platform and branch the code here? Note that I haven't tried this on Android yet so I don't even know if my code works there.
Currently, if my device has no internet connection AND the user is not logged into GameCenter, none of the leaderboard stuff appears. I was thinking there would be an automated error message or something, but attempting to authenticate just has no reaction in game (so in my case it looks like a button that does nothing). Do I have to detect this authenticate fail state on my own and display a message, or does Unity connect to built-in OS messaging that I can tie into?
Lastly, in the event that the player uninstalls and re-installs the app (which wipes the PlayerPrefs where I locally store the highscore), is there a way to check the online leaderboards to get a player's previous highscore and pull it into the game? I would expect a Social.GetScore() method, but there isn't one. If I can't do this then the game will attempt to post scores to the leaderboard that are smaller than previous ones posted by the same user... and I'm not even sure what will happen in that case.
Sorry for the wall of text. Any help is much appreciated.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Send email with attachment 1 Answer
Post Data on Twitter 1 Answer
Calling an android method from Unity3D with a JAR plugin 0 Answers
Share text message on selected media 1 Answer