GCLeaderBoard.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace UnityEngine.SocialPlatforms.GameCenter
  4. {
  5. public class GCLeaderBoard : MonoBehaviour
  6. {
  7. private const string _leaderBoardID = "SANTA_BEST_SCORE";
  8. private static bool _authDone;
  9. private static bool _authProcess;
  10. // Use this for initialization
  11. void Start()
  12. {
  13. if (!_authProcess)
  14. {
  15. Social.localUser.Authenticate (OnAuth);
  16. _authProcess = true;
  17. }
  18. Debug.Log("GCLeaderBoard::Started");
  19. }
  20. private static void OnSummitScore(bool done)
  21. {
  22. Debug.Log ("OnSummitScore " + done);
  23. }
  24. private void OnAuth(bool done)
  25. {
  26. Debug.Log ("OnAuth " + done);
  27. _authDone = done;
  28. _authProcess = false;
  29. }
  30. public static void Show()
  31. {
  32. if (Social.localUser.authenticated)
  33. {
  34. Social.ShowLeaderboardUI();
  35. }
  36. else
  37. {
  38. Social.localUser.Authenticate(OnAuthAndShow);
  39. }
  40. }
  41. private static void OnAuthAndShow(bool done)
  42. {
  43. Social.ShowLeaderboardUI();
  44. Debug.Log("OnAuthAndShow " + done);
  45. }
  46. public static void SummitScore(long score)
  47. {
  48. if (_authDone)
  49. {
  50. Social.ReportScore(score, _leaderBoardID, OnSummitScore);
  51. }
  52. /* else
  53. {
  54. _lastScore = score;
  55. Social.localUser.Authenticate(OnAuthAndSummitScore);
  56. }*/
  57. }
  58. /* private static long _lastScore;
  59. private static void OnAuthAndSummitScore(bool done)
  60. {
  61. Social.ShowLeaderboardUI();
  62. Debug.Log("OnAuthAndSummitScore " + done);
  63. Social.ReportScore(_lastScore, _leaderBoardID, OnAuthAndSummitScore);
  64. }*/
  65. }
  66. }