Advertisement
Guest User

HelloPartyLogic

a guest
Jun 11th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using PlayFab;
  2. using PlayFab.Party;
  3. using PlayFab.ClientModels;
  4. using UnityEngine;
  5.  
  6. public class HelloPartyLogic : MonoBehaviour
  7. {
  8.     public static HelloPartyLogic Instance;
  9.  
  10.     private void Awake()
  11.     {
  12.         if (Instance != null) Destroy(Instance.gameObject);
  13.         else Instance = this;
  14.  
  15.         DontDestroyOnLoad(this);
  16.  
  17.     }
  18.     public void Start()
  19.     {
  20.         ////Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
  21.         //if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
  22.         //{
  23.         //    PlayFabSettings.TitleId = "11845"; // Please change this value to your own titleId from PlayFab Game Manager
  24.         //}
  25.         //var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true };
  26.         //PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
  27.     }
  28.  
  29.     private void OnLoginSuccess(LoginResult result)
  30.     {
  31.        // Debug.Log("Congratulations, you made your first successful API call!");
  32.     }
  33.  
  34.     private void OnLoginFailure(PlayFabError error)
  35.     {
  36.         //Debug.LogWarning("Something went wrong with your first API call.  :(");
  37.         //Debug.LogError("Here's some debug information:");
  38.         //Debug.LogError(error.GenerateErrorReport());
  39.     }
  40.  
  41.     public void JoinRoom(string s)
  42.     {
  43.         if(s=="")
  44.         {
  45.             PlayFabMultiplayerManager.Get().CreateAndJoinNetwork();
  46.             PlayFabMultiplayerManager.Get().OnNetworkJoined += OnNetworkJoined;
  47.         }
  48.         if(s!="")
  49.         {
  50.             Debug.Log("here");
  51.             PlayFabMultiplayerManager.Get().JoinNetwork(s);
  52.             PlayFabMultiplayerManager.Get().OnNetworkJoined += OnNetworkJoined;
  53.         }
  54.     }
  55.  
  56.  
  57.     private void OnNetworkJoined(object sender, string networkId)
  58.     {
  59.         // Print the Network ID so you can give it to the other client.
  60.         Debug.Log(networkId);
  61.     }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement