Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using PlayFab;
- using PlayFab.ClientModels;
- public class PlayFabManager : MonoBehaviour
- {
- // PlayFab ID Default --> change it
- // Petvenger Dev >> androidvn.com@gmail.com /1q2w3e4r5t@123
- public string PlayfabID = "FD55";
- public string CustomAccountID = "";
- // Time
- public int TimeStartCheckToken = 30;
- public int TimePeriodCheckToken = 30;
- public static PlayFabManager Instance;
- private bool isDoneDownTitleData = false;
- private bool isDoneDownDataUser = false;
- void Awake()
- {
- DontDestroyOnLoad(this);
- Instance = this;
- PlayFabSettings.TitleId = PlayfabID;
- Login("iduser");
- }
- [ContextMenu("Login PlayFab")]
- public void Login(string CustomAccountLogin)
- {
- print("Login with " + CustomAccountLogin);
- LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
- {
- TitleId = PlayfabID,
- CreateAccount = true,
- CustomId = CustomAccountLogin
- };
- PlayFabClientAPI.LoginWithCustomID(
- request,
- (result) =>
- {
- CustomAccountID = result.PlayFabId;
- Debug.Log("Got PlayFabID: " + CustomAccountLogin);
- if (result.NewlyCreated)
- {
- Debug.Log("(new account)");
- setDisplayName("Name Display In PlayFab");
- }
- else
- {
- Debug.Log("(existing account)");
- }
- },
- (error) =>
- {
- Debug.Log("Error logging in player with custom ID:");
- Debug.Log(error.ErrorMessage);
- }
- );
- }
- private void setDisplayName(String displayName)
- {
- UpdateUserTitleDisplayNameRequest request = new UpdateUserTitleDisplayNameRequest()
- {
- DisplayName = displayName
- };
- PlayFabClientAPI.UpdateUserTitleDisplayName(
- request,
- (result) =>
- {
- print("Current name in playfab: " + result.DisplayName);
- },
- (error) =>
- {
- Debug.Log(error.ErrorMessage);
- }
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement