Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Game Center login problem

Discussion in 'Scripting' started by JJNCreator, Aug 29, 2018.

  1. JJNCreator

    JJNCreator

    Joined:
    Jul 3, 2012
    Posts:
    28
    Hi Unity users,

    I'm making an iOS game that uses the native Social API to log in to Game Center. It was working fine before, but for some reason, it will no longer log in. It almost looks like the sign in function isn't being called, because there wasn't any debug info in Xcode, not even an error. I tried everything; I did a clean build, updated Unity, checked my info on the Apple Dev site, got rid of duplicates. None of this worked. Is there anything else I could try? Any help would be much appreciated as I'm somewhat new to this Social API.

    Code for my Game Center Manager:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SocialPlatforms;
    5.  
    6. #if UNITY_IOS
    7. using UnityEngine.SocialPlatforms.GameCenter;
    8. #endif
    9.  
    10. public static class NewGameCenterManager {
    11.     public static bool IsGCUseLoggedIn {
    12.         get {
    13.             return Social.localUser.authenticated;
    14.         }
    15.     }
    16.     public static string GCUsername {
    17.         get {
    18.             return Social.Active.localUser.userName;
    19.         }
    20.     }
    21.     public static void SignIn(System.Action<bool> callback) {
    22.         Social.localUser.Authenticate(callback);
    23.     }
    24.     public static void UnlockAchievement(string id) {
    25.         if(IsGCUseLoggedIn) {
    26.             Social.ReportProgress(id, 100, null);
    27.         }
    28.     }
    29.     public static void IncrementAchievement(string id, double progress) {
    30.         if (IsGCUseLoggedIn)
    31.         {
    32.             Social.ReportProgress(id, progress, null);
    33.         }
    34.     }
    35.     public static void UpdateLeaderboard(string id, long score) {
    36.         if(IsGCUseLoggedIn) {
    37.             Social.ReportScore(score, id, null);
    38.         }
    39.  
    40.     }
    41.     public static void ShowAchievements() {
    42.         if(IsGCUseLoggedIn) {
    43.             Social.ShowAchievementsUI();
    44.         }
    45.        
    46.     }
    47.     public static float GetAchievementProgress(string id) {
    48.         return System.Convert.ToSingle(GameSettings.gameCenterAchievements[id].percentCompleted);
    49.     }
    50.     public static void ResetAchievements() {
    51.         if(IsGCUseLoggedIn) {
    52.             GameCenterPlatform.ResetAllAchievements(null);
    53.         }
    54.     }
    55. }
    56.  
     
    davidharutyunyan97 likes this.