본문 바로가기

카테고리 없음

[Unity3D] Leaderboard 등록

반응형
public void LoadLeaderboard()
{
        #if UNITY_ANDROID
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();

        #elif UNITY_IOS
        GameCenterPlatform.ShowDefaultAchievementCompletionBanner(true);
        #endif

        Social.localUser.Authenticate(AuthenticateHandler);
    }

    void AuthenticateHandler(bool isSuccess)
    {
        if(isSuccess)
        {
            int bestScore = SaveData.GetBestScore();
            Social.ReportScore((long)bestScore, leaderboardId, (bool bSuccess) =>
            {
                #if UNITY_ANDROID
                    PlayGamesPlatform.Instance.ShowLeaderboardUI(leaderboardId);
                    
                #elif UNITY_IOS
                    Social.ShowLeaderboardUI();
                #endif
            });
        }
    }


반응형