Hello, I am developing a project in unity and photon and playfab are integrated into my project. In the login (registration phase), I make users choose 1 profile photo and upload it to the playfab entity files. Since I want users to be able to see the picture of other users in the room when they set up a room, I am trying to download the profile photo selected by the user at login from the playfab entity file. I have a prefab showing the users in the room and the code file is in this prefab
public class playerprafab : MonoBehaviourPunCallbacks { [SerializeField] private Text _text; [SerializeField] private Image profilep2; public bool Ready = false; public Player Player { get; private set; } public int GlobalFileLock = 0; private string entityId; // Id representing the logged in player private string entityType; // entityType representing the logged in player private readonly Dictionary<string, string> _entityFileJson = new Dictionary<string, string>(); public void SetPlayerInfo(Player player) { Player = player; _text.text = player.NickName; } void OnSharedFailure(PlayFabError error) { Debug.LogError(error.GenerateErrorReport()); GlobalFileLock -= 1; } void OnLogin(LoginResult result) { entityId = result.EntityToken.Entity.Id; // The expected entity type is title_player_account. entityType = result.EntityToken.Entity.Type; Debug.Log(entityType + entityId); } public void LoadAllFiles() { if (GlobalFileLock != 0) throw new Exception("This example overly restricts file operations for safety. Careful consideration must be made when doing multiple file operations in parallel to avoid conflict."); GlobalFileLock += 1; // Start GetFiles var request = new PlayFab.DataModels.GetFilesRequest { Entity = new PlayFab.DataModels.EntityKey { Id = entityId, Type = entityType } }; PlayFabDataAPI.GetFiles(request, OnGetFileMeta, OnSharedFailure); } void Start() { PlayFabAuthenticationAPI.GetEntityToken(new GetEntityTokenRequest(), (entityResult) => { var entityId = entityResult.Entity.Id; var entityType = entityResult.Entity.Type; }, OnPlayFabError); LoadAllFiles(); } void OnGetFileMeta(PlayFab.DataModels.GetFilesResponse result) { Debug.Log("Loading " + result.Metadata.Count + " files"); _entityFileJson.Clear(); foreach (var eachFilePair in result.Metadata) { _entityFileJson.Add(eachFilePair.Key, null); GetActualFile(eachFilePair.Value); } GlobalFileLock -= 1; // Finish GetFiles } void GetActualFile(PlayFab.DataModels.GetFileMetadata fileData) { GlobalFileLock += 1; // Start Each SimpleGetCall PlayFabHttp.SimpleGetCall(fileData.DownloadUrl, result => { _entityFileJson[fileData.FileName] = Encoding.UTF8.GetString(result); GlobalFileLock -= 1; }, // Finish Each SimpleGetCall error => { Debug.Log(error); } ); } void OnPlayFabError(PlayFabError error) { Debug.Log(error.GenerateErrorReport()); } }
Result : I can't access Entity Key .
/File/GetFiles: Invalid input parameters EntityKey: Type or TypeString is required. EntityKey: Id is required. EntityKey: is not an allowed value of Type.
This prefab is loaded after login, when the user joins or sets up the room. I'm already logged in, why can't I access the entity key.
Question I want to ask: - How can I call OnLogin() inside Start()? - I have an image named profilep2. I want the image that I will download from entity files to be synchronized to profilep2, how and where can I do this in the code file