박준희 2021. 6. 22. 15:15

플랫폼 의존 컴파일

https://docs.unity3d.com/kr/530/Manual/PlatformDependentCompilation.html

 

유니티 - 매뉴얼: 플랫폼 의존 컴파일

자동 메모리 관리를 이해하기 플랫폼 의존 컴파일 Unity는 “플랫폼 의존 컴파일”이라는 기능이 있습니다. 여기에는 몇 가지 전 처리기 지시문이 포함되어, 스크립트를 ’파티션화’하여 코드

docs.unity3d.com

 

 

구글 소셜 정보 취득

코드

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();
    }
}