반응형

안녕하세요

유니티에서 PlayFab을 연동해보도록 하겠습니다.

일단 PlayFab 사이트에 가서 가입을 해야합니다.

https://playfab.com/

 

Full Stack LiveOps, Real-Time Control

PlayFab is a suite of products that complement your existing backend infrastructure. Mix and match to meet your needs, or adopt the entire platform as a powerful base for current and future games.

playfab.com

 

가입 후 이메일 인증을 하고나면 다음과 같은 화면이 나옵니다.

기본적으로 만들어져있는 My Game으로 작업을 해도 되고, "New Studio"버튼을 눌러서 새로운 프로젝트를 만들어도 됩니다.

그 후 "Take our Tutorial"을 클릭합니다.

 

Turtorial 페이지가 나옵니다.

여기서 SDKs > PlayFab SDKs > Game engines > Unity3D > Quickstart로 이동해서 "PlayFab Unity Editor Extensions Asset Package"를 클릭 후 유니티 패키지를 다운로드 받습니다.

그리고 실행해서 PlayFab을 사용할 유니티 프로젝트에 해당 패키지를 임포트합니다.

임포트를 하면 다음과 같은 창이 나타나는데, 회원가입창이기 때문에 로그인창으로 이동해야 합니다. 로그인 창으로 이동을 위해서  "LOG IN"을 클릭합니다.

회원가입 시 등록했던 이메일과 패스워드를 입력해서 로그인합니다.

로그인을 하면 "No SDK is installed."이라고 뜨면서 SDK가 설치되지 않았다고 뜨는데, "Install PlayFab SDK"버튼을 클릭합니다.

SDK설치가 완료되면 다음과 같이 창이 바뀌게 되는데, 여기서 "SETTINGS" 탭을 클릭합니다.

여기서 추가했던 STUDIO로 변경해줍니다.

다음과 같은 형식이 됩니다.

연결을 확인하기 위해서 빈오브젝트를 생성하고 스크립트를 추가합니다.

 

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
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;
 
public class PlayFabLogin : MonoBehaviour
{
    public void Start()
    {
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId)){
            /*
            Please change the titleId below to your own titleId from PlayFab Game Manager.
            If you have already set the value in the Editor Extensions, this can be skipped.
            */
            PlayFabSettings.staticSettings.TitleId = "42";
        }
        var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true};
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
    }
 
    private void OnLoginSuccess(LoginResult result)
    {
        Debug.Log("Congratulations, you made your first successful API call!");
    }
 
    private void OnLoginFailure(PlayFabError error)
    {
        Debug.LogWarning("Something went wrong with your first API call.  :(");
        Debug.LogError("Here's some debug information:");
        Debug.LogError(error.GenerateErrorReport());
    }
}
cs

 

실행 후 콘솔에 "Congratulations, you made your first successful API call!" 

가 출력되면 연동에 성공했다는 것을 의미합니다. 

반응형

+ Recent posts