using System.Collections; using System.Collections.Generic; using PlayFab; using PlayFab.ClientModels; using UnityEngine; using UnityEngine.SceneManagement; public class PlayFabInit : MonoBehaviour { public string playFabTitleId = "7D3B9"; // Replace with your PlayFab Title ID void Start() { 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!"); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } private void OnLoginFailure(PlayFabError error) { Debug.LogError("Login failed: " + error.GenerateErrorReport()); } }