[Unity] 유니티 플러그인, Unity Plugin, GPGS로그인
APP 2020. 1. 29. 17:16
1.깃허브의 플러그인 받기
https://github.com/playgameservices/play-games-plugin-for-unity
2.압축을 풀면 나오는 유니티 패키지를 내가 빌드한 유니티 프로젝트에 풀어넣기
3.jdk 다운로드( Windows x64로 받음)
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
4.환경변수 설정
윈도우 키 누르고 환경이라고 검색하면 시스템 환경 변수 편집 나옴
환경변수>>시스템변수>>새로만들기 에서
변수이름을 JAVA_HOME
디렉터리 찾아보기로 나의자바가 설치된 폴더를 선택한다. (C:\Program Files\Java\jdk1.8.0_241)
시스템변수 Path로 들어가서 새로만들기
%JAVA_HOME%\bin
이라고 추가해준다.
5. GPGS 라이브러리 받기
Resolve에 성공했다면 GPGSIds라는 스크립트가 생긴다
6. GPGS를 위한 코드 작성하기
Init 메서드 안에 있는 내용은 github의
Configuration & Initialization Play Game Services 부분에 있고 필요없는 부분은 주석처리 하였다.
GPGSManager 스크립트
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
56
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
public class GPGSManager : MonoBehaviour
{
public static GPGSManager instance;
public void Awake()
{
GPGSManager.instance = this;
}
public void Init()
{
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
// enables saving game progress.
//.EnableSavedGames()
// registers a callback to handle game invitations received while the game is not running.
// .WithInvitationDelegate(< callback method >)
// registers a callback for turn based match notifications received while the
// game is not running.
//.WithMatchDelegate(< callback method >)
// requests the email address of the player be available.
// Will bring up a prompt for consent.
//.RequestEmail()
// requests a server auth code be generated so it can be passed to an
// associated back end server application and exchanged for an OAuth token.
//.RequestServerAuthCode(false)
// requests an ID token be generated. This OAuth token can be used to
// identify the player to other services such as Firebase.
//.RequestIdToken()
.Build();
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate();
}
public void SignIn(System.Action<bool> complete)
{
// authenticate user:
Social.localUser.Authenticate((bool success) =>
{
// handle success or failure
complete(success);
});
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
Test스크립트
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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
public Button btnSignIn;
public Text txt;
public System.Action<bool> OnComplete;
// Start is called before the first frame update
void Start()
{
OnComplete = (success) =>
{
};
this.btnSignIn.onClick.AddListener(() =>
{
Debug.Log("SignIn Button Pressed");
});
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'APP' 카테고리의 다른 글
[Unity] 프로젝트 동영상 (0) | 2020.02.01 |
---|---|
[Unity] 페이스북로그인샘플, FaceBook Login Sample (0) | 2020.01.30 |
[Unity] Visual Studio 프로젝트 오픈시 마이그레이션이 필요합니다 또는 호환되지 않음 (1) | 2020.01.22 |
[Unity] 2020.01.03 NGUI 캐릭터Info, Slider, Label, Json 로드 및 저장 (0) | 2020.01.03 |
[Unity] 2019.12.18 UIPopup, UIInventory, UIItem (0) | 2019.12.18 |