public void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope) { // Check if user has logged in if (!VerifyUser()) { OnShowLeaderboardViewFinished(Constants.kGameServicesUserAuthMissingError); return; } // Application needs to be in play mode if (!Application.isPlaying) { OnShowLeaderboardViewFinished("The operation could not be completed because view is available only in play mode."); return; } // Get leaderboard info EGCLeaderboard _gcLeaderboard = GetLeaderboardWithID(_leaderboardID); if (_gcLeaderboard == null) { OnShowLeaderboardViewFinished(Constants.kGameServicesIdentifierInfoNotFoundError); return; } // Set leaderboard score fetch range Range _oldRange = _gcLeaderboard.Range; Range _newRange = new Range(1, int.MaxValue); // Fetch scores from leaderboard _gcLeaderboard.FilterScoreList(_timeScope, eLeaderboardUserScope.GLOBAL, _newRange); // Reset range to old value _gcLeaderboard.Range = _oldRange; // Show UI if (m_gameCenterUI == null) { CreateGameCenterUIInstance(); } m_gameCenterUI.ShowLeaderboardUI(_gcLeaderboard.GetLastQueryResults(), () => { // Invoke handler OnShowLeaderboardViewFinished(null); }); }
protected override void LoadScoresFinished(IDictionary _dataDict) { string _error = _dataDict.GetIfAvailable <string>(EditorGameCenter.kErrorKey); EGCLeaderboard _leaderboardInfo = _dataDict.GetIfAvailable <EGCLeaderboard>(EditorGameCenter.kLeaderboardInfoKey); if (_leaderboardInfo != null) { // Update title Title = _leaderboardInfo.Title; // Update scores SetScores(_leaderboardInfo.GetLastQueryResults(), _leaderboardInfo.LocalUserScore); } // Call finish handler LoadScoresFinished(Scores, LocalUserScore, _error); }
protected override void LoadScoresFinished(IDictionary _dataDict) { EditorScore[] _scores = null; EditorScore _localUserScore = null; // Parse received information string _error = _dataDict.GetIfAvailable <string>(EditorGameCenter.kErrorKey); EGCLeaderboard _leaderboardInfo = _dataDict.GetIfAvailable <EGCLeaderboard>(EditorGameCenter.kLeaderboardInfoKey); if (_leaderboardInfo != null) { string _title = _leaderboardInfo.Title; EGCScore[] _egcScores = _leaderboardInfo.GetLastQueryResults(); EGCScore _egcLocalUserScore = _leaderboardInfo.LocalUserScore; if (_egcScores != null) { int _count = _egcScores.Length; _scores = new EditorScore[_count]; for (int _iter = 0; _iter < _count; _iter++) { _scores[_iter] = new EditorScore(_egcScores[_iter]); } } if (_egcLocalUserScore != null) { _localUserScore = new EditorScore(_egcLocalUserScore); } // Update leaderboard properties this.Title = _title; } // Invoke finish handler LoadScoresFinished(_scores, _localUserScore, _error); }