Explain.
앞서 GPGS활용을위한 셋팅까지 완료한경우
Unity Project에서 GPGS의 기본적은 기능(업적 , 리더보드)를 활용하기위한 Class 생성.
아래 방법은 여러가지 방법중 하나이므로 프로젝트 상황에 맞게끔 구현하여 사용하면 됩니다.
![]() |
1. Google Game service의 리더보드,업적의 경우 Id값을 기준으로 실행이 이뤄지므로 Developer Console의 업적,리더보드에서 Get Resources를 클릭하여 ID값을 복사 |
![]() |
2.위 처럼 텍스트 형식으로 Export하여 복사하여 둡니다. |
이후 아래처럼 GPGS Manager Class를 생성한 뒤 Scene에 배치후
이벤트 관련 동작시(게임종료)
업적,리더보드관련 메소드를 호출하여 동작을 확인해 보실수있습니다.
리더보드 , 업적 확인 관련 UI호출은
ShowLeaderBoard, ShowArchievement
메소드를 호출하여 확인가능.
이상으로 GPGS의 기본적인 기능들 활용방법 포스팅 마치겠습니다.
이벤트 관련 동작시(게임종료)
업적,리더보드관련 메소드를 호출하여 동작을 확인해 보실수있습니다.
리더보드 , 업적 확인 관련 UI호출은
ShowLeaderBoard, ShowArchievement
메소드를 호출하여 확인가능.
이상으로 GPGS의 기본적인 기능들 활용방법 포스팅 마치겠습니다.
using UnityEngine; using System.Collections; using GooglePlayGames; using UnityEngine.SocialPlatforms; public class GPGSManager : MonoBehaviour { private static GPGSManager sInstance; public static GPGSManager GetInstance { get { if(sInstance == null) sInstance = this; return sInstance; } } void Start() { init(); } void init() { PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.Activate(); Social.localUser.Authenticate((bool success) => { if (success) Debug.Log("Sign in Success"); else Debug.Log("Sign in Fail"); }); } public void PostScore(float time) { Social.ReportScore((long)(time * 1000), IDs.LB, (bool success) => { if (success) Debug.Log("Post Success"); else Debug.Log("Post Fail"); }); } public void ProgessiveAchievement(AchievementType type, int value) { if (type == AchievementType.PlayCount) { //TODO : 업적 상황 달성시 postAchievement(업적ID); } if(type == AchievementType.PlayTime) { //TODO : 업적 상황 달성시 postAchievement(업적ID); } } public void ShowLeaderboard() { Social.ShowLeaderboardUI(); } public void ShowAchievement() { Social.ShowAchievementsUI(); } private void postAchievement(string key) { if (PlayerPrefs.GetInt(key) == (int)AchievementState.UNLOCK) return; Social.ReportProgress(key, 100, (bool success) => { if (success) { PlayerPrefs.SetInt(key, (int)AchievementState.UNLOCK); } }); } } // 업적 , 리더보드 ID Class public class IDs { public const string LB = ""; // 리더보드 ID //TODO : 업적 ID 추가. } public enum AchievementType { PlayCount, PlayTime } public enum AchievementState { LOCK, UNLOCK }