using System; using System.Collections; using System.Collections.Generic; using PlayFab; using PlayFab.ClientModels; using UnityEngine; public class PlayFabUserData : MonoBehaviour { public PlayerProfileModel myProfile; public Dictionary myCustomData; public void GetPlayerUserData(string playfabID, Action> onCallback, Action onFallback) { var request = new GetPlayerCombinedInfoRequest { PlayFabId = playfabID, // Use the logged-in player's PlayFab ID InfoRequestParameters = new GetPlayerCombinedInfoRequestParams { GetUserData = true // This will include User Data like AvatarID in the response } }; PlayFabClientAPI.GetPlayerCombinedInfo(request, result => onCallback(result.InfoResultPayload.UserData), result=>onFallback(result.ErrorMessage)); } public void GetPlayerAvatarImage(string playfabID, Action onCallback, Action onFallback) { var request = new GetPlayerCombinedInfoRequest { PlayFabId = playfabID, // Use the logged-in player's PlayFab ID InfoRequestParameters = new GetPlayerCombinedInfoRequestParams { GetUserData = true // This will include User Data like AvatarID in the response } }; PlayFabClientAPI.GetPlayerCombinedInfo(request, result => { if (result.InfoResultPayload.UserData != null && result.InfoResultPayload.UserData.ContainsKey("AvatarID")) { Sprite dp = PlayFabManager.Instance.avatarImages[ int.Parse(result.InfoResultPayload.UserData["AvatarID"].Value)]; onCallback(dp); } else onCallback(PlayFabManager.Instance.avatarImages[0]); }, result=>onFallback(result.ErrorMessage)); } }