구글 플레이 게임 서비스(GPGS) 기능 스크립트 작성
* GooglePlayGames, GooglePlayGames.BasicApi 네임스페이스 사용
using GooglePlayGames;
using GooglePlayGames.BasicApi;
* 플레이 게임 클라이언트 구성 필요
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestServerAuthCode(false).Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
* 로그인 상태 확인 및 로그인 하기
if (Social.localUser.authenticated) // GPGS 로그인 되어 있는 경우
{
}
else // GPGS 로그인이 되어 있지 않은 경우
{
Social.localUser.Authenticate((bool Success) =>
{
if (Success) //로그인 시도 성공
{
}
else //로그인 실패
{
}
});
}
* 로그아웃
((PlayGamesPlatform)Social.Active).SignOut(); //로그아웃
세부적인 내용은 아래에서 참고 가능하다.
playgameservices/play-games-plugin-for-unity
Google Play Games plugin for Unity. Contribute to playgameservices/play-games-plugin-for-unity development by creating an account on GitHub.
github.com
https://firebase.google.com/docs/auth/unity/play-games?hl=ko
Unity에서 Google Play 게임 서비스를 사용하여 인증하기 | Firebase
Google Play 게임 서비스를 사용하여 Firebase 및 Unity를 기반으로 개발된 Android 게임에 플레이어가 로그인하도록 할 수 있습니다. Firebase를 통한 Google Play 게임 서비스 로그인을 사용하려면 우선 Google Play 게임에 플레이어를 로그인 처리하면서 OAuth 2.0 인증 코드를 요청합니다. 그런 다음 PlayGamesAuthProvider에 인증 코드를 전달하여 Firebase 사용자 인증 정보를 생성합니다.
firebase.google.com
반응형
'Unity' 카테고리의 다른 글
[Unity] 유니티와 AWS DynamoDB 연결 (1) | 2019.08.26 |
---|---|
[Unity] 유니티와 AWS Cognito 연동하기 (2) | 2019.08.26 |
[Unity] 구글 플레이 게임 서비스(GPGS) 연동 (0) | 2019.08.11 |
[Unity] 구글 플레이 스토어 APK 분할 업로드 방법 (0) | 2019.08.11 |
[Unity] 배경 음악 랜덤 플레이 (0) | 2019.08.11 |