Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. using PlayFab;
  7. using PlayFab.ClientModels;
  8. using System.Net;
  9.  
  10. public class EntryInterface : MonoBehaviour {
  11.  
  12. public InputField UsernameInput;
  13. public InputField PasswordInput;
  14.  
  15. public void LoginRequest()
  16. {
  17. string username = UsernameInput.text;
  18. string password = PasswordInput.text;
  19.  
  20. LoginWithPlayFabRequest loginRequest = new LoginWithPlayFabRequest();
  21. loginRequest.Username = username;
  22. loginRequest.Password = password;
  23.  
  24. PlayFabClientAPI.LoginWithPlayFab(loginRequest, (result) =>
  25. {
  26. LocalPlayer.Instance.PlayFabID = result.PlayFabId;
  27.  
  28. MatchmakeRequest matchmakeRequest = new MatchmakeRequest();
  29. matchmakeRequest.BuildVersion = "Awesome";
  30. matchmakeRequest.GameMode = "Default";
  31. matchmakeRequest.Region = Region.USCentral;
  32. matchmakeRequest.StartNewIfNoneFound = true;
  33.  
  34. PlayFabClientAPI.Matchmake(matchmakeRequest, (x) => {
  35. NetworkClient.Instance.ConnectInBackground(IPAddress.Parse(x.ServerHostname), (int)x.ServerPort, NetworkClient.Instance.IPVersion);
  36. }, (error) => {
  37. Debug.Log(error.ErrorMessage);
  38. NetworkClient.Instance.ConnectInBackground(NetworkClient.Instance.Address, NetworkClient.Instance.Port, NetworkClient.Instance.IPVersion);
  39. });
  40.  
  41. Debug.Log("Successfully logged '" + result.PlayFabId + "' into PlayFab");
  42. }, (error) =>
  43. {
  44. Debug.Log(error.ErrorMessage);
  45. });
  46. }
  47.  
  48. public void OfflineMode()
  49. {
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement