Advertisement
Guest User

PlayFabLogin

a guest
Jun 11th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using PlayFab;
  2. using PlayFab.ClientModels;
  3. using UnityEngine;
  4. using PlayFab;
  5. using PlayFab.Party;
  6. using PlayFab.ClientModels;
  7. public class PlayFabLogin : MonoBehaviour
  8. {
  9.     public void Start()
  10.     {
  11.         //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
  12.         if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
  13.         {
  14.             PlayFabSettings.TitleId = "11845"; // Please change this value to your own titleId from PlayFab Game Manager
  15.         }
  16.         var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true };
  17.         PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
  18.     }
  19.  
  20.     private void OnLoginSuccess(LoginResult result)
  21.     {
  22.         Debug.Log("Congratulations, you made your first successful API call!");
  23.  
  24.         PlayFabMultiplayerManager.Get().OnRemotePlayerJoined += OnRemotePlayerJoined;
  25.         PlayFabMultiplayerManager.Get().OnRemotePlayerLeft += OnRemotePlayerLeft;
  26.     }
  27.  
  28.     private void OnLoginFailure(PlayFabError error)
  29.     {
  30.         Debug.LogWarning("Something went wrong with your first API call.  :(");
  31.         Debug.LogError("Here's some debug information:");
  32.         Debug.LogError(error.GenerateErrorReport());
  33.     }
  34.  
  35.     private void OnRemotePlayerJoined(object sender, PlayFabPlayer player)
  36.     {
  37.         var localPlayer = PlayFabMultiplayerManager.Get().LocalPlayer;
  38.         Debug.Log("localplayer"+localPlayer.ToString());
  39.     }
  40.  
  41.     private void OnRemotePlayerLeft(object sender, PlayFabPlayer player)
  42.     {
  43.     }
  44.  
  45.    
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement