0% found this document useful (0 votes)
6 views2 pages

PlayFabManager Cs

Uploaded by

shlokpatel3469
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

PlayFabManager Cs

Uploaded by

shlokpatel3469
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine.SceneManagement;
using System;

public class PlayFabManager : MonoBehaviour


{

//private string LocalPlayFabID;

// Start is called before the first frame update


void Start()
{
Login();
}

void Login()
{
var request = new LoginWithCustomIDRequest
{
CustomId = SystemInfo.deviceUniqueIdentifier,
CreateAccount = true
};
PlayFabClientAPI.LoginWithCustomID(request, OnSuccess, OnError);
}

void OnSuccess(LoginResult result)


{
Debug.Log("Successful login/account create!");

PlayFabPlayerLoggedIn();

string pUsername = PlayerPrefs.GetString("username");

PlayFabClientAPI.UpdateUserTitleDisplayName(new
UpdateUserTitleDisplayNameRequest
{
DisplayName = pUsername
}, delegate (UpdateUserTitleDisplayNameResult result)
{
Debug.Log("Display Name Changed!");
}, delegate (PlayFabError error)
{
Debug.Log("Error");
Debug.Log(error.ErrorDetails);
});

//LocalPlayFabID = result.PlayFabId;

void OnError(PlayFabError error)


{
Debug.Log("Error while logging in/creating account!");
if (error.Error == PlayFabErrorCode.AccountBanned)
{
Debug.Log("PLAYER IS BANNED");

}
SceneManager.LoadScene("Bans");
}
Debug.Log(error.GenerateErrorReport());
}

public virtual void PlayFabPlayerLoggedIn()


{

//public override void OnConnectedToMaster()


//{
//var Hash = PhotonNetwork.LocalPlayer.CustomProperties;
//Hash.Add("PlayFabPlayerID", LocalPlayFabID);
//Debug.Log(PhotonNetwork.LocalPlayer.CustomProperties["PlayFabPlayerID"]);
//}

You might also like