public void getHighestScore() { #if UNITY_ANDROID //leaderboardID = ANDROIDlbID1; leaderboardID = AndroidLBName; #elif UNITY_IPHONE //leaderboardID = IOSlbID1; leaderboardID = IOSLBName; #endif ILeaderboard lb = Social.CreateLeaderboard(); lb.id = leaderboardID; lb.SetUserFilter(new string[] { Social.localUser.id }); lb.LoadScores((bool success) => { if (success) { if (lb.scores.Length > 0) { Debug.Log("Got user's score: " + lb.scores.GetValue(0).ToString()); } else { Debug.Log("lb.scores.Length is 0."); } } else { Debug.Log("Did not get the user's score."); } }); }
/// <summary> /// 获得我的排名 /// </summary> /// <param name="id"></param> /// <param name="onComplete"></param> public void GetMyScore(string id, System.Action <bool, IScore> onComplete) { if (!Social.localUser.authenticated) { return; } ILeaderboard lb = Social.CreateLeaderboard(); lb.id = id; lb.SetUserFilter(new string[] { Social.localUser.id }); lb.LoadScores(b => { onComplete(b, lb.localUserScore); }); }
private void FetchCurrentUserScore(string id, LeaderboardTimeSpan timeSpan) { if (!userSignedIn || leaderboardUserLoadState != LeaderboardLoadState.DoneLoading) { return; } leaderboardUserLoadState = LeaderboardLoadState.LoadingValues; curUserLeaderboardItem.cachedGo.SetActive(false); // Hide current result while loading. curUserLeaderboard = PlayGamesPlatform.Instance.CreateLeaderboard(); curUserLeaderboard.id = id; curUserLeaderboard.range = new Range(int.MaxValue, 0); // We are only getting our local value. So this range doesn't matter. curUserLeaderboard.SetUserFilter(curUserFilter); curUserLeaderboard.timeScope = TimeSpanToTimeScope(timeSpan); curUserLeaderboard.LoadScores(OnLoadedCurrentUserScore); }
public static void GetLeaderboard(string id, string userid, Action <long> callbackSuccess = null, Action callbackFailure = null) { ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard(); lb.id = id; lb.SetUserFilter(new string[] { userid }); lb.LoadScores(ok => { if (ok) { if (callbackSuccess != null) { callbackSuccess.Invoke(lb.localUserScore.value); } } else { if (callbackFailure != null) { callbackFailure.Invoke(); } } }); }