구글플레이 업적과 리더보드 만들기!





GoogleManager.Cs 소스입니다




using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using UnityEngine.UI;

public class GoogleManager : MonoBehaviour
{
    public Text LogText;
    public InputField ScoreInput;


    void Awake()
    {
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.Activate();
        LogIn();
    }

    public void LogIn()
    {
        Social.localUser.Authenticate((bool success) =>
        {
            if (success) LogText.text = Social.localUser.id + " \n " + Social.localUser.userName;
            else LogText.text = "구글 로그인 실패";
        });
    }

    public void LogOut()
    {
        ((PlayGamesPlatform)Social.Active).SignOut();
        LogText.text = "구글 로그아웃";
    }



    public void ShowAchievementUI() => Social.ShowAchievementsUI();

    public void UnlockAchievement_1() => Social.ReportProgress(GPGSIds.achievement_one, 100, (bool success) => { });

    public void UnlockAchievement_2() => Social.ReportProgress(GPGSIds.achievement_two, 100, (bool success) => { });

    public void UnlockAchievement_3() => PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement_three, 1, (bool success) => { });



    public void ShowLeaderboardUI() => Social.ShowLeaderboardUI();

    public void ShowLeaderboardUI_4() => ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(GPGSIds.leaderboard_four);

    public void AddLeaderboard_5() => Social.ReportScore(int.Parse(ScoreInput.text), GPGSIds.leaderboard_five, (bool success) => { });
}