GPGS 로그인

Unity3D 2018. 11. 27. 18:35
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using UnityEngine.Networking;
 
public class App : MonoBehaviour {
 
    public Text textVersion;
    public Text textDetail;
    public Image thumbImage;
 
    public GPGSManager gpgsManager;
    private Texture2D texture;
 
 
    // Use this for initialization
    void Start () {
        this.textVersion.text = Application.version.ToString();
        this.gpgsManager.Init();
        this.gpgsManager.OnLoadedImage = () => {
            var texture = Social.localUser.image;
            var sp = Sprite.Create(texture, new Rect(00, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100f);
            this.thumbImage.sprite = sp;
        };
        this.gpgsManager.SignIn((result) => { });
 
    }
 
    // Update is called once per frame
    void Update () {
        
    }
}
 
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames.BasicApi;
using GooglePlayGames;
 
public class GPGSManager : MonoBehaviour {
 
    public System.Action OnLoadedImage;
    public void Init()
    {
        PlayGamesClientConfiguration conf = new PlayGamesClientConfiguration.Builder().Build();
        PlayGamesPlatform.InitializeInstance(conf);
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.Activate();
        Debug.LogFormat("GPGSManager::Init");
    }
 
    public void SignIn(System.Action<bool> onComplete)
    {
        Debug.LogFormat("GPGSManager::SignIn");
 
        Social.localUser.Authenticate((result) => {
            if (result)
            {
                Debug.Log("Authentication Successed.");
                Debug.LogFormat("id: {0}, userName: {1}, underage: {2}", Social.localUser.id, Social.localUser.userName, Social.localUser.underage);
                Debug.LogFormat("image: {0}", Social.localUser.image);
                this.StartCoroutine(this.LoadImage());
            }
            else
            {
                Debug.Log("Authentication Failed.");
            }
 
            onComplete(result);
        });
 
    }
 
    private IEnumerator LoadImage()
    {
        yield return ((PlayGamesLocalUser)Social.localUser).LoadImage();
        Debug.LogFormat("image: {0}", Social.localUser.image);
        this.OnLoadedImage();
    }
 
    
 
    // Update is called once per frame
    void Update () {
        
    }
}
 
cs


반응형

'Unity3D' 카테고리의 다른 글

GPGS 리더보드  (0) 2018.11.29
GPGS 업적  (0) 2018.11.28
IAP 테스트 (영수증검증)  (0) 2018.10.23
Socket.IO-Client-Unity3D  (0) 2018.10.19
Sending a form to an HTTP server (POST) Using IMultipartFormSection  (0) 2018.10.19
: