2018년 1월 1일 월요일

Google Play Service / Apple Game Center 연동

영문 메뉴얼

우선은 구글에서 만들어둔 플러그인을 사용
GitHub 페이지 ( https://github.com/playgameservices/play-games-plugin-for-unity )


다운 받아서 압축 푼다.
풀린 파일 있는 폴더의 경로에 플러그인이 있다.



이 플러그인은 구글 플레이 게임서비스와 애플 게임센터 두 플랫폼 다 지원함
출처: http://minhyeokism.tistory.com/70 [programmer-dominic.kim]

이 플러그인은 구글 애플 둘다 지원한다는데 해봐야 아는거다.

우선 다운로드 받은 플러그인을 유니티에 적용

다음, 구글 콘솔 사이트에 들어가서 앱 추가 또는 정보 확인

게임 서비스 / 연결된 앱 확인


업적 / 리더보드 작성



리소스 받기  눌러서 아래와 같은 화면이 나오게 하고



안드로이드 탭 상태에서 내용을 복사

유니티의 아래 메뉴 그림을 참고하여


구글 플레이 게임 - 안드로이드 셋업 창 열어

아래와 같이 복사한 내용을 붙여 넣는다.


Setup 버튼을 눌러 준다.

정상 처리 되면 아래와 같이
GPGSIds 라는 cs 파일이 생성됨



그 내용은 아래와 같으며 업적의 잠금 해제나 리더보드에 스코어 올릴때
GPGSIds 라는 static 클래스의 string 변수를 이용함







본격 진행전 설명

필요한 using
using GooglePlayGames;
using GooglePlayGames.BasicApi;
//using UnityEngine.SocialPlatforms;// 이건 보류
using UnityEngine.SocialPlatforms.GameCenter;

코드 부분은 아래와 같이 한다.



좀더 자세하게는
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        // enables saving game progress.
        .EnableSavedGames()
        // registers a callback to handle game invitations received while the game is not running.
        .WithInvitationDelegate(<callback method>)
        // registers a callback for turn based match notifications received while the
        // game is not running.
        .WithMatchDelegate(<callback method>)
        // requests the email address of the player be available.
        // Will bring up a prompt for consent.
        .RequestEmail()
        // requests a server auth code be generated so it can be passed to an
        //  associated back end server application and exchanged for an OAuth token.
        .RequestServerAuthCode(false)
        // requests an ID token be generated.  This OAuth token can be used to
        //  identify the player to other services such as Firebase.
        .RequestIdToken()
        .Build();

    PlayGamesPlatform.InitializeInstance(config);
    // recommended for debugging:
    PlayGamesPlatform.DebugLogEnabled = true;
    // Activate the Google Play Games platform
    PlayGamesPlatform.Activate();
출처 : Configuration & Initialization Play Game Services 를 ctrl + f


다음으로는 Sign In
주석 처리된 GooglePlayGames.PlayGamesPlatform.Instance.Authenticate....
부분은 영문 메뉴얼에 그렇게 안되있어서 일단 주석처리


Sign Out



Player Statistics


Setting popup gravity