You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
954 B
C#
40 lines
954 B
C#
1 month ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using PlayFab;
|
||
|
using PlayFab.ClientModels;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class PlayFabInit : MonoBehaviour
|
||
|
{
|
||
1 month ago
|
public string playFabTitleId = "7D3B9"; // Replace with your PlayFab Title ID
|
||
1 month ago
|
void Start()
|
||
|
{
|
||
1 month ago
|
|
||
1 month ago
|
if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
|
||
|
{
|
||
|
PlayFabSettings.TitleId = playFabTitleId;
|
||
|
}
|
||
|
Login();
|
||
|
}
|
||
|
|
||
|
void Login()
|
||
|
{
|
||
|
var request = new LoginWithCustomIDRequest
|
||
|
{
|
||
|
CustomId = SystemInfo.deviceUniqueIdentifier,
|
||
|
CreateAccount = true
|
||
|
};
|
||
|
PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
|
||
|
}
|
||
|
|
||
|
private void OnLoginSuccess(LoginResult result)
|
||
|
{
|
||
|
Debug.Log("Login successful!");
|
||
|
}
|
||
|
|
||
|
private void OnLoginFailure(PlayFabError error)
|
||
|
{
|
||
|
Debug.LogError("Login failed: " + error.GenerateErrorReport());
|
||
|
}
|
||
|
}
|