참고: onionisdelicious.tistory.com/69?category=808633
[Unity/Theory] 구글 플레이와 연동하여 기능을 구현하자! (로그인)
!!! NOTICE !!! 이 글은 유니티의 이론을 다루고 있습니다! 학습한 정보를 제가 기억하고 추후에도 사용해두기 위해 기록해둔 내용입니다! 이 점 유의하고 봐주세요! 지난 글에서는 유니티 프로젝트
onionisdelicious.tistory.com
github.com/playgameservices/play-games-plugin-for-unity/tree/master/current-build
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
다운로드 받아서 Unity Project에 Import 함
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.UI;
public class GooglePlayManager : MonoBehaviour
{
public Text loginStatusText;
private void Awake()
{
PlayGamesPlatform.InitializeInstance(new PlayGamesClientConfiguration.Builder().Build());
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
}
public void Login()
{
if(!Social.localUser.authenticated)
{
Social.localUser.Authenticate((bool isSuccess) =>
{
if(isSuccess)
{
Debug.Log("인증 성공 -> " + Social.localUser.userName);
loginStatusText.text = "Success";
}
else
{
Debug.Log("인증 실패");
loginStatusText.text = "Fail";
}
}
);
}
}
public void Logout()
{
((PlayGamesPlatform)Social.Active).SignOut();
loginStatusText.text = "Logout";
}
}
Unity에서 실행하면 안되고, PlayConsole에서 테스터 추가하고 앱에 깔아서 해야 한다.
'Unity > Unity 리서치' 카테고리의 다른 글
Unity와 Firebase Firestore 데이터 연동 (0) | 2021.05.16 |
---|---|
Unity Firebase 연동 (0) | 2021.05.15 |
Unity 구글 플레이와 연동하기 - (1) (0) | 2021.05.06 |
MRTK 환경에서 Object에 그림자가 심하게 질때 (0) | 2020.12.19 |
Unity MRTK(Mixed Reality Toolkit)환경 구성 (0) | 2020.12.13 |