Search Unity

Game Center Support

Discussion in 'iOS and tvOS' started by DigitalDuane, Dec 26, 2011.

  1. hieu.ivieoh

    hieu.ivieoh

    Joined:
    Dec 16, 2010
    Posts:
    12
    i got the way to solved my problems : So if i log out my current account, and log in another account and report score, the result is ok. But it required me to log out the current account from Game Center when i want to submit score. How could i do if i want to submit every time i want without log out the GC?
     
  2. Le_nain

    Le_nain

    Joined:
    Jun 20, 2011
    Posts:
    47
    You can't natively know when the user closes the panel by clicking on the "done" button. But you can workaround =>

    - In Unity there is the OnApplicationPause(bool pause) function that is called (as you can guess) when the engine is paused/unpaused. It's used that way
    Code (csharp):
    1. protected void OnApplicationPause(bool pause)
    2. {
    3.     Debug.Log("PAUSE: " + pause);
    4.        
    5.     // App pausing
    6.     if(pause)
    7.     {
    8.         // Do something
    9.     }
    10.     else
    11.     {
    12.         // Do something else
    13.     }
    14.  
    - This will be called every time the unity engine loses the focus, like (list not exhaustive) when an AlertView is opened, the app is backgrounded (e.g. the user presses the "home" button), you call the UnityPause() function in your code... So if you need to detect the specific case where you're going to/coming back from the GC Leaderboard, just toggle a bool "openedLeaderboardPanel" before making the actual call to the GC panel and test it within the OnUnityPause() function
     
  3. Ari-Levi

    Ari-Levi

    Joined:
    Dec 3, 2011
    Posts:
    13
    I have been trying to submit scores for the last couple of days to no avail.

    It authenticates gamecenter and welcomes me back, says in the Debug Console that it successfully reported a score, but "no Score" always pops up every time I check the boards.

    I have logged in with 3 different sandbox accounts who are all friends. The game comes up in the list of games on games center but it also says "Never Played" and "Not Ranked" on the leaderboards.

    I've checked the box to enable gameCenter:


    Here's my leaderboard setup:


    this is my code for reporting (almost pulled word for word from the documentation):

    Code (csharp):
    1. void SetHighScore(int highScore)
    2.     {
    3.         if(Social.localUser.authenticated)
    4.             ReportScore(highScore,"High_Scores"); //
    5.     }
    6.    
    7.     void ReportScore (long score, string leaderboardID) {
    8.         Debug.Log ("Reporting score " + score + " on leaderboard " + leaderboardID);
    9.         Social.ReportScore (score, leaderboardID, success => {
    10.         Debug.Log(success ? "Reported score successfully" : "Failed to report score");
    11.         Debug.Log("New Score:"+score);
    12.        });
    13. }
    It says reporting successful, but it does that even if I put a completely random leaderboard ID.

    I want to Submit an update for my app and this is what is stopping me. If anyone can see errors or give advice I will be grateful.
     
  4. Ari-Levi

    Ari-Levi

    Joined:
    Dec 3, 2011
    Posts:
    13
    OnApplicationPause() doesn't work for me when the game center login pops up.

    It works for when the app loses focus though, via home button/phone call.
     
  5. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    92
    Craftmaster/others: It doesn't matter for our game when the default game center views are closed, so it's not a concern for us ( I know, that's of no help :) ) ... However, it gets even worse because I ran into a bug where clicking the DONE button on the default game center leader board view wouldn't actually close that window. It was stuck!

    We have two leader boards, it comes up defaulted to your "default" leader board. I think I pressed the home button so the game plus leader board view lost focus. Came back and done wouldn't work. Fortunately pressing the back button to go to all leader boards and then selecting another one actually re-enabled that button, but that's going to be confusing for the user. I can't find a reliable repro for this unfortunately.

    That said, I would recommend just grabbing the leader board data directly and displaying the content/view yourself in a GUI if it's that important you get notified when they close the view. That's the only way to be sure.

    Edit: oh.. And I came here wondering why my scores weren't posting. Nice to read the responses here. Thanks guys.
     
  6. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    if the same Achievements is reported more than one time within a very short interval, the popup will be shown more than one time.
     
  7. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    540
    It might be the Unity 3.5.2f2 (latest release) iOS autorotation issue ?
     
  8. ToniGuillem

    ToniGuillem

    Joined:
    Jan 25, 2012
    Posts:
    3
    Is there any way to specify to Social.ShowLeaderboardUI() which leaderboard do you want to show?

    I know that you can load a specific leaderboard with Social.LoadScore() and its identifier, but it would be useful to be able to show a specific Leaderboard from GameCenter, not just the 'Default' one.
     
  9. Gaspedal

    Gaspedal

    Joined:
    Mar 29, 2009
    Posts:
    368
    OK
    Reporting Achievements and displaying on GameCenter works fine! After waiting 6 hours, now I can see my reported scores. :)
     
    Last edited: Jun 7, 2012
  10. Peter Hou

    Peter Hou

    Joined:
    Oct 12, 2010
    Posts:
    66
    Last edited: Jun 14, 2012
  11. paulbaker

    paulbaker

    Joined:
    Aug 29, 2012
    Posts:
    58
    Has anyone worked out this problem where the banner doesn't show when going from x% to 100%?
     
  12. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    Is there anybody using Unity's built-in GC without a problem? (which is currently live on the store)
     
  13. nocanwin

    nocanwin

    Joined:
    May 7, 2009
    Posts:
    141
    I have one currently waiting for review. It's pretty minimal, just a leaderboard. I didn't have any problems using the sandbox. I'll let you know how it goes.
     
  14. CH

    CH

    Joined:
    Jul 4, 2012
    Posts:
    109
    We're currently implementing Game Center as well, but I wonder two things...

    1. Is is really necessary to connect to Game Center in every scene? According to the Editor it is (it gives an error when there's no Authenticate() in the scene), but you'd think this is something for the first scene...

    2. Performance is rather slow on older devices and the frame rate drops significantly when the Game Center notification is about to appear. Are there any ways to give the Game Center process something like 'a lower priority'?
     
  15. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    147
    Guys, I'm using Social.LoadScores http://docs.unity3d.com/Documentation/ScriptReference/Social.LoadScores.html but it is returning only the highest score in my leader board, i.e. the length of the array is 1, then as soon as my test friend beats the max score, it returns just that one.

    I though it would return an array with all my friend's scores.

    Any clue why this is happening?

    The scores on game center show up fine, and they are updated with no problem.

    Edit: Used ILeaderboard.LoadScores instead
     
    Last edited: Sep 5, 2012
  16. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    I'm on the edge of buying Prime31's plug-in. Not sure If a can risk it.
     
  17. nocanwin

    nocanwin

    Joined:
    May 7, 2009
    Posts:
    141
    it's out and working... well except for a bug of my own creation. Stupid me, I put in some last minute code to make sure your score was successfully submitted and ended up making is so only your first high score got submitted. That's what I get for being a QA army of one.

    It's fixed now and I've got an update waiting for review.
     
  18. paulbaker

    paulbaker

    Joined:
    Aug 29, 2012
    Posts:
    58
    Has anyone got the banner to show up when going from x% to 100% (where x > 0)?
     
  19. devast3d

    devast3d

    Joined:
    May 30, 2010
    Posts:
    76
    Hi, is there any news on how to choose default leaderboard for the ShowLeaderboardUI() method?
    I have found the following link http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/LeaderBoards/LeaderBoards.html which says
    It's clear that such thing is theoretically possible but unity api hasn't exposed it.
    --
    btw, I'm using 3.5.6 version
     
  20. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    138
    Hi everyone,

    Recently, I've started to work on the achievement system for our game using the Unity3D Social API. I would like to ensure that any achievements obtained by the user while s/he is offline are automatically posted as soon as there is internet connectivity. I managed to do this by saving the IDs of those achievements that failed the submission process. As soon as the game starts, it automatically loads those achievements and tries to post them again. Although this works, I was thinking if such feature is already implemented in the Social API. I tried to submit an achievement while offline however when I connected to the Internet and restarted the game, the achievement wasn't resubmitted. I receive false from the ReportProgress method (which is expected). This is the code that I originally tried with. Am I missing something?

    Thanks

    Code (csharp):
    1.  
    2. public void PostAchievement(string achievementId, float percentCompleted){
    3.         if(string.IsNullOrEmpty(achievementId)){
    4.             Debug.Log("Achievement ID is null");
    5.             return;
    6.         }
    7.        
    8.         if(Social.localUser.authenticated){            
    9.             Debug.Log("Setting achievement with ID - " + achievementId + " to " + percentCompleted);
    10.            
    11.             if(!IsAchievementComplete(achievementId)){
    12.                 Social.ReportProgress(achievementId, percentCompleted, (bool success) => {
    13.                     Debug.Log("Progress report success - " + success);
    14.                    
    15.                     if(success){
    16.                         Debug.Log("Progress for achievement ID " + achievementId + " has been reported successfully");
    17.                         LoadAchievements();
    18.                     }else{
    19.                         Debug.Log("Progress for achievement ID " + achievementId + " was not reported.");
    20.                     }
    21.                 });
    22.             }else{
    23.                 Debug.Log("Progress for achievement ID " + achievementId + " has already been reported");
    24.             }
    25.         }else{
    26.             Debug.Log("User not authenticated");
    27.         }
    28.     }
    29.  
     
  21. MissVi

    MissVi

    Joined:
    Apr 2, 2013
    Posts:
    7
    Did you ever found a solution? I have this same problem and can't find a solution. The completion banner seems to only show when the achievement progress is set to 100% straight away, but if it's gradual reporting, cumulative (eg. 25% each progress report so you need to submit it 4 times to complete the achievement) then it doesn't show the banner once it reaches 100%.

    Solution anyone?
     
  22. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,011
    Edit:eek:ops wrong thread
     
    Last edited: Mar 14, 2014
  23. Jammer3000

    Jammer3000

    Joined:
    Nov 27, 2013
    Posts:
    5
    Hi nocanwin, I have gamecenter working properly and it comes up and everything in sandbox mode on the device but I dont know how to make it display my high score of my game or even how to set that up at all and I cant seem to find it anywhere could you show me how you did it?!
     
  24. bingheliefeng

    bingheliefeng

    Joined:
    May 8, 2014
    Posts:
    12
    How to show all leaderboards
     
  25. Moghul

    Moghul

    Joined:
    Sep 8, 2013
    Posts:
    2
    Hey, I was wondering if the Game Center is now working properly in the latest versions (4.something). I have to implement an achievement system soon and I need to inform my supervisor whether or not we have to pay the $75 for the prime31 version or if we can get away with this fine and dandy. I need to be able to unlock achievements, show them, upload score and show the leaderboard.

    Thank you very much for your time and any help is much appreciated
     
  26. CH

    CH

    Joined:
    Jul 4, 2012
    Posts:
    109
    In Gluddle on iOS Game Center (native Unity) has been implemented (implemented about a year ago?). What we did was set a timeout for loading the next level (scene) because the app would crash if loading a next scene while submitting data to Game Center. Don't know if that's still the case, though.
     
  27. Ill-Fish

    Ill-Fish

    Joined:
    Aug 23, 2015
    Posts:
    12
    Hi,

    I'm looking for a way to sign out from Game Center with my own button inside the game. But I can't find anything.

    In the Android version of my game I use this for Google Play Game sign out:

    Code (csharp):
    1. ((PlayGamesPlatform)Social.Active).SignOut();
    Now I'm looking for a way to do the same with the Game Center.
     
  28. Jakhongir

    Jakhongir

    Joined:
    May 12, 2015
    Posts:
    37
    when testing, accidentaly inserted HUGE scores to gamecenter leaderboard, how to change this value to lower?
     
  29. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Hey,

    As we know, if the player declines to log into GameCenter, iOS can block future requests to show the login window. Is there anyway to detect this?

    What I'm seeing is if I call Authenticate and the iOS blocks the login screen, I never get a callback to inform me that the Authentication request failed. I think this is important to know in my opinion.
     
  30. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    428
    Unfortunately this is not possible as far as I know.

    When testing personally, I use several accounts for cases like this and in a while I nuke the scoreboard data in testflight.
     
  31. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Hmm, this complicates things. I wonder has anybody been able to get around this?

    We are trying to log the user into our game via GameCenter, falling back to Facebook if that fails. But if we never get notified that the login was blocked, we do not know to fallback to Facebook.
     
unityunity