Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using PlayFab;
- using PlayFab.Party;
- using PlayFab.ClientModels;
- using UnityEngine;
- public class HelloPartyLogic : MonoBehaviour
- {
- public static HelloPartyLogic Instance;
- private void Awake()
- {
- if (Instance != null) Destroy(Instance.gameObject);
- else Instance = this;
- DontDestroyOnLoad(this);
- }
- public void Start()
- {
- ////Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
- //if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
- //{
- // PlayFabSettings.TitleId = "11845"; // Please change this value to your own titleId from PlayFab Game Manager
- //}
- //var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true };
- //PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
- }
- private void OnLoginSuccess(LoginResult result)
- {
- // Debug.Log("Congratulations, you made your first successful API call!");
- }
- private void OnLoginFailure(PlayFabError error)
- {
- //Debug.LogWarning("Something went wrong with your first API call. :(");
- //Debug.LogError("Here's some debug information:");
- //Debug.LogError(error.GenerateErrorReport());
- }
- public void JoinRoom(string s)
- {
- if(s=="")
- {
- PlayFabMultiplayerManager.Get().CreateAndJoinNetwork();
- PlayFabMultiplayerManager.Get().OnNetworkJoined += OnNetworkJoined;
- }
- if(s!="")
- {
- Debug.Log("here");
- PlayFabMultiplayerManager.Get().JoinNetwork(s);
- PlayFabMultiplayerManager.Get().OnNetworkJoined += OnNetworkJoined;
- }
- }
- private void OnNetworkJoined(object sender, string networkId)
- {
- // Print the Network ID so you can give it to the other client.
- Debug.Log(networkId);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement