반응형
구글 플레이 콘솔에서 Play 게임즈 서비스 -> 설정 및 관리 -> 업적 클릭하면 업적 만들기를 할 수 있습니다.
리더보드의 경우에는 업적 아래의 리더보드를 클릭하여 생성 가능합니다.
이렇게 생성된 업적과 리더 보드를 유니티 프로젝트에 적용시키기 위해서는 해당 리소스가 필요합니다.
설정 및 관리 -> 설정으로 가서 사용자 인증 정보의 리소스 보기를 클릭하여 코드들을 복사합니다.
유니티 프로젝트로 가서 window -> google play games -> setup -> Android setup을 클릭
이후 뜨는 창에 붙여넣어준 후 setup 버튼을 클릭하면 유니티 코드에서 구글 업적으로 접근이 가능해집니다.
public void AddClickCnt()
{
clickCount.text = clickCnt.ToString();
// 리더보드에 접근
PlayGamesPlatform.Instance.ReportScore(clickCnt + 1, GPGSIds.leaderboard_click,
(bool success) =>
{
if (success)
{
clickCnt++;
clickCount.text = "Click Count : " + clickCnt.ToString();
IncrementGPGSAchievement();
}
});
}
// 모든 업적 정보 열기
public void ShowAchievementUI()
{
PlayGamesPlatform.Instance.ShowAchievementsUI();
}
// 리더 보드 열기
public void ShowLeaderboardUI()
{
PlayGamesPlatform.Instance.ShowLeaderboardUI(GPGSIds.leaderboard_click);
}
// 업적 점수 올리기
public void IncrementGPGSAchievement()
{
PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement__10, 1, (bool success) =>
{
IAchievement acv;
_achievements.TryGetValue(GPGSIds.achievement__10, out acv);
if (acv != null && acv.completed)
UnlockingGPGSAchievement();
});
PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement_20, 1, (bool success)=>{});
}
// 업적 잠금 해제
public void UnlockingGPGSAchievement()
{
PlayGamesPlatform.Instance.UnlockAchievement(GPGSIds.achievement_20);
}
반응형
LIST
'Unity' 카테고리의 다른 글
unity gradle build failed (0) | 2024.12.19 |
---|---|
Google Sign in Plugin 임포트시 발생하는 에러 해결법 (1) | 2024.12.17 |
유니티 퀘스트 설계 아이디어 (ScriptableObject) (0) | 2024.07.07 |
Unity Instantiate (1) | 2024.06.11 |
Unity JsonUtility (0) | 2024.05.31 |