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

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

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

« 이전 버전 2 현재 »

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();

Unreal

#include "KakaoGame.h"
  
// Whether or not the user is logged into Google Game
bool isLoggedIn = FKGGoogleGames::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
        }
    }
});

Unreal

#include "KakaoGame.h"
  
FKGGoogleGames::Login(FKGResultDelegate::CreateLambda([=](FKGResult 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
        }
    }
});

Unreal

#include "KakaoGame.h"
 
FKGGoogleGames::Logout(FKGResultDelegate::CreateLambda([=](FKGResult 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);

Unreal

#include "KakaoGame.h"
  
FString id = TEXT(""); // Achievement ID
FKGGoogleGamesAchievements::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);

Unreal

#include "KakaoGame.h"
  
FString id = TEXT(""); // Achievement ID
FKGGoogleGamesAchievements::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);

Unreal

#include "KakaoGame.h"
  
FString id = TEXT(""); // Achievement ID
int32 numSteps = 20; // The value of the level to be increased
 
// Achievements increased
FKGGoogleGamesAchievements::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);

Unreal

#include "KakaoGame.h"
  
FString id = TEXT(""); // Achievement ID
int32 numSteps = 20; // The value of the level to be increased
 
// Set steps completed.
FKGGoogleGamesAchievements::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);

Unreal

#include "KakaoGame.h"
  
// Show the Google Game Achievements screen
FKGGoogleGamesAchievements::ShowAchievementView();

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");

 Unreal

#include "KakaoGame.h"
  
FString id = TEXT("CgkI8vSF8d4YEAIQBg"); // Leaderboard Id
int64 score = 100;                       // score
FString tag = TEXT("");                  // tag
 
FKGGoogleGamesLeaderboards::SubmitScore(id, score, tag);

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);

Unreal

#include "KakaoGame.h"
  
FString id = TEXT("CgkI8vSF8d4YEAIQBg"); // Leaderboard Id
// Ranking period
// NONE(Not setting), 0 (Daily), 1 (Weekly), 2 (All)
int32 timeSpan = -1;
 
// Show the Google Game Leaderboard screen
FKGGoogleGamesLeaderboards::ShowLeaderboardView(id, timeSpan);


  • 레이블 없음