-
06/22 GPGS 테스트 2게임 플랫폼 응용프로그래밍 2021. 6. 22. 15:15
플랫폼 의존 컴파일
https://docs.unity3d.com/kr/530/Manual/PlatformDependentCompilation.html
구글 소셜 정보 취득
코드
app.cs
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using GooglePlayGames; using GooglePlayGames.BasicApi; using UnityEngine.SocialPlatforms; public class App : MonoBehaviour { public Text versionText; public Text txtid; public Text txtUserName; public Text txtState; public Image thumb; void Start() { versionText.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) => { // handle results Debug.Log("================================>" + result); Debug.Log("================================>" + Social.localUser); Debug.Log("================================>" + 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); 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(); } }
'게임 플랫폼 응용프로그래밍' 카테고리의 다른 글
06/25 웹뷰 (0) 2021.06.25 06/24 네이버로그인 (0) 2021.06.24 06/24 GPGS 4 리더보드 (0) 2021.06.24 06/23 GPGS 3 업적 (0) 2021.06.23 06/18~19 유니티 어플 구글 플레이 콘솔에 등록 및 로그인 구현 연습 (0) 2021.06.17