0617 GPGS
2021. 6. 17. 11:41ㆍNode.js
1. 녹스 설치
2. 구글 플레이 개발자 콘솔 로그인
3. https://github.com/playgameservices/play-games-plugin-for-unity
소스 다운로드
4. 유니티 새 프로젝트 만들기, 안드로이드로 플랫폼 변경
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
https://drehzr.tistory.com/711
위의 블로그 그대로 따라하면 된다.
더보기
CommandInvokationFailure : Gradle build failed 오류가 날 시 해결법
https://happyryu.tistory.com/138
위 블로그 참고하기
구글 로그인 구현
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class App : MonoBehaviour
{
public Text txtVersion;
// Start is called before the first frame update
void Start()
{
this.txtVersion.text = Application.version;
Debug.Log("================================= init GPGS =================================");
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.Build();
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate();
Debug.Log("================================= authenticate =================================");
// authenticate user:
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, (result) => {
Debug.Log("================================= result =================================");
});
}
}
코드 작성 후 앱 새로 빌드
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;
public class App : MonoBehaviour
{
public Text txtVersion;
public Text txtId;
public Text txtUsername;
public Text txtState;
public Image thumb;
// Start is called before the first frame update
void Start()
{
this.txtVersion.text = Application.version;
Debug.Log("================================= init GPGS =================================");
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.Build();
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate();
Debug.Log("================================= authenticate =================================");
// authenticate user:
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptAlways, (result) => {
Debug.Log("================================= result ================================="+result);
Debug.Log("================================= local User ================================="+ Social.localUser);
Debug.Log("================================= autenciated =================================" + Social.localUser.authenticated);
this.txtId.text = Social.localUser.id;
this.txtUsername.text = Social.localUser.userName;
this.txtState.text = Social.localUser.state.ToString();
StartCoroutine(this.WaitforLoadThumb(() =>
{
Debug.Log(Social.localUser.image);
Debug.LogFormat("{0}{1}", Social.localUser.image.width, Social.localUser.image.height);
this.thumb.sprite = Sprite.Create(Social.localUser.image, new Rect(0, 0, Social.localUser.image.width,Social.localUser.image.height), Vector2.zero);
this.thumb.SetNativeSize();
}));
});
}
private IEnumerator WaitforLoadThumb(System.Action callback)
{
while (true)
{
if (Social.localUser.image != null)
{
break;
}
yield return null;
}
callback();
}
}
'Node.js' 카테고리의 다른 글
Naver login (0) | 2021.06.24 |
---|---|
GPGS Achievement (0) | 2021.06.23 |
0616 Sequelize (0) | 2021.06.16 |
0615 express서버와 mysql 커넥션 (0) | 2021.06.15 |
0611 express 서버 이어서 (0) | 2021.06.11 |