I'm trying to integrate Game Center into my Unity 5 project and facings troubles. It seems that authentification is OK when the game starts on iOS device, a notification appears, but leaderboard button does not work, nothing happens when I tap GC button. I assigned the initiation of "ShowLeaderboard()" to GC button. Please, take a look at the script I use below. Hope to find a resolution for my issue. Thank you in advance.
using UnityEngine;
using UnityEngine.SocialPlatforms;
using UnityEngine.SocialPlatforms.GameCenter;
using System.Collections;
public class GameCenter : MonoBehaviour {
public string leaderboardID = "mygameleaderboard";
void Start () {
AuthenticateToGameCenter();
}
private bool isAuthenticatedToGameCenter;
public static void AuthenticateToGameCenter() {
#if UNITY_IPHONE
Social.localUser.Authenticate(success => {
if (success) {
Debug.Log("Authentication successful");
} else {
Debug.Log("Authentication failed");
}
});
#endif
}
public static void ReportScore(long score, string leaderboardID) {
#if UNITY_IPHONE
Debug.Log("Reporting score " + score + " on leaderboard " + leaderboardID);
Social.ReportScore(score, leaderboardID, success => {
if (success) {
Debug.Log("Reported score successfully");
} else {
Debug.Log("Failed to report score");
}
});
#endif
}
//call to show leaderboard
public static void ShowLeaderboard() {
#if UNITY_IPHONE
Social.ShowLeaderboardUI();
#endif
}
}
