using UnityEngine;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class GPGSIntegration : MonoBehaviour
{
long bestScore;
void GetLeaderBoardScore()
{
ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard();
// GPGS에서 생성한 GPGSIds 클래스 리더보드 변수명
lb.id = GPGSIds.leaderboard_bestscore;
lb.LoadScores(scores =>
{
bestScore = lb.localUserScore.value;
});
}
}
그리고 리더보드의 정보를 획득해 다음과 같이 가공할 수 있다.
using UnityEngine;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class GPGSIntegration : MonoBehaviour
{
long bestScore;
void ShowLeaderBoardMyInfo()
{
ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard();
// GPGS에서 생성한 GPGSIds 클래스 리더보드 변수명
lb.id = GPGSIds.leaderboard_bestscore;
lb.userScope = UserScope.Global;
lb.range = new Range(1,10);
lb.timeScope = TimeScope.AllTime;
lb.LoadScores(scores =>
{
uint all_player = lb.maxRange;
int my_rank = lb.localUserScore.rank;
decimal percent = (decimal)my_rank / (decimal)all_player;
text.text = scores.ToString() + "\nAllPlayer: " + all_player + "\nMyRank: " + my_rank + "\nMyScore: " +lb.localUserScore.value.ToString() + "\nPercent: " + percent + "%";
});
}
}
출력 정보출처 : https://stackoverflow.com/questions/55234701/google-play-games-leaderboard-custom
댓글 없음:
댓글 쓰기