메타 데이터의 끝으로 건너뛰기
메타 데이터의 시작으로 이동

이 페이지의 이전 버전을 보고 있습니다. 현재 버전 보기.

현재와 비교 페이지 이력 보기

버전 1 다음 »

31.1. Google Game SDK Example (android only)


31.1.1. Check if the user is logged into Google Game

Unity

using Kakaogame.SDK;
  
// Whether or not the user is logged into Google Game
bool isLoggedIn = KGGoogleGames.isLoggedIn;

Android

// Whether or not the user is logged into Google Game
boolean isLoggedIn = KGGoogleGames.isLoggedIn();

31.1.2. Google game login

Unity

KGGoogleGames.Login((result) =>
{
    if (result.isSuccess)
    {
        // Login successful
    }
    else
    {
        // Login failed
    }
});

Android

KGGoogleGames.login(activity, new KGResultCallback<Void>() {
    @Override
    public void onResult(KGResult<Void> result) {
        if (result.isSuccess()) {
            // Login successful
        } else {
            // Login failed
        }
    }
});

31.1.3. Google game logout

Unity

using Kakaogame.SDK;
 
KGGoogleGames.Logout((result) =>
{
    if (result.isSuccess)
    {
        // Logout successful
    }
    else
    {
        // Logout failed
    }
});

Android

KGGoogleGames.logout(new KGResultCallback<Void>() {
    @Override
    public void onResult(KGResult<Void> result) {
        if (result.isSuccess()) {
            // Logout successful
        } else {
            // Logout failed
        }
    }
});

31.1.4. Complete achievements

Unity

using Kakaogame.SDK;
  
string id; // Achievement ID
KGGoogleGamesAchievements.Unlock(id);

Android

String id; // Achievement ID
KGGoogleGamesAchievements.unlock(id);

31.1.5. Display achievements

Unity

using Kakaogame.SDK;
  
string id; // Achievement ID
KGGoogleGamesAchievements.Reveal(id);

Android

String id; // Achievement ID
KGGoogleGamesAchievements.reveal(id);

31.1.6. Incremental achievements

Unity

using Kakaogame.SDK;
  
string id; // Achievement ID
int numSteps; // The value of the level to be increased
 
// Achievements increased
KGGoogleGamesAchievements.Increment(id, numSteps);

Android

String id; // Achievement ID
int numSteps; // The value of the level to be increased
 
// Achievements increased
KGGoogleGamesAchievements.increment(id, numSteps);

31.1.7. Set achievement completion level

This is an example of setting up a step-like achievement.

Unity

using Kakaogame.SDK;
  
string id; // Achievement ID
int numSteps; // The value of the level to be increased
 
// Set steps completed.
KGGoogleGamesAchievements.SetSteps(id, numSteps);

Android

String id; // Achievement ID
int numSteps; // The value of the level to be increased
 
// Set steps completed.
KGGoogleGamesAchievements.setSteps(id, numSteps);

31.1.8. Show the Achievements screen

This is an example showing achievement screen.

Unity

using Kakaogame.SDK;
  
// Show the Google Game Achievements screen
KGGoogleGamesAchievements.ShowAchievementView();

Android

// Show the Google Game Achievements screen
KGGoogleGamesAchievements.showAchievementView(activity);

31.1.9. Set a score in the Leaderboard

This is an example of setting a score in Google Game Leaderboard.

Unity

string id = "CgkI8vSF8d4YEAIQBg";   // Leaderboard Id
long score = 100;                   // score
string tag = "";                    // tag
  
  
// Set a score in Google Game Leaderboard
KGGoogleGamesLeaderboards.SubmitScore(id, score, tag);

Android

String id; // Leaderboard Id
int score; // score
  
// Set a score in Google Game Leaderboard
KGGoogleGamesLeaderboards.submitScore(id, 100, "Stage1");

 

31.1.10. Show the Leaderboard screen

This is an example showing leaderboard screen.

Unity

string id = "CgkI8vSF8d4YEAIQBg";   // Leaderboard Id
// Ranking period
// NONE(Not setting), 0 (Daily), 1 (Weekly), 2 (All)
int timeSpan = -1;                
  
  
// Show the Google Game Leaderboard screen
KGGoogleGamesLeaderboards.ShowLeaderboardView(id, timeSpan);

Android

String id; // Leaderboard Id
// Ranking period
// NONE(Not setting), DAILY (daily), WEEKELY (weekly), ALL_TIME (all) 
KGTimeSpan span = KGGoogleGamesLeaderboards.KGTimeSpan.WEEKLY;
  
// Show the Google Game Leaderboard screen
KGGoogleGamesLeaderboards.showLeaderboardView(activity, id, span);


  • 레이블 없음