In the login section of the application (register), I make the user choose a profile photo and upload this photo to playfab. I then have the user download this image when they join a room. But the photo of all the users in the room is the same. Each user sees the photo of other players on their own screen as their own photo. If there are 4 players in the room, the same photo is downloaded 4 times.
How can I view their own picture of other players in the room?
My code file is almost identical to the one in this document( https://docs.microsoft.com/en-us/gaming/playfab/features/data/entities/quickstart ). I am sending you the different places:
To upload the photo :
private void GaleridenResimCek(int maksimumBuyukluk) { NativeGallery.Permission izin = NativeGallery.GetImageFromGallery((konum) => { Debug.Log("Seçilen resmin konumu: " + konum); if (konum != null) { // Seçilen resmi bir Texture2D'ye çevir Texture2D texture = NativeGallery.LoadImageAtPath(konum, maksimumBuyukluk); System.IO.File.Copy(konum, Application.persistentDataPath + "/SavedImage.png", true); if (texture == null) { Debug.Log(konum + " konumundaki resimden bir texture oluşturulamadı."); return; } profilep.sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); } }, "Bir resim seçin", "image/png"); } void OnInitFileUpload(PlayFab.DataModels.InitiateFileUploadsResponse response) { var payload = File.ReadAllBytes(Application.persistentDataPath + "/SavedImage.png"); GlobalFileLock += 1; // Start SimplePutCall PlayFabHttp.SimplePutCall(response.UploadDetails[0].UploadUrl, payload, FinalizeUpload, error => { Debug.Log(error); } ); GlobalFileLock -= 1; // Finish InitiateFileUploads }
To download the photo : (This code file is inside the prefab, which is added to the player list content, which contains the player's profile photo and username.)
void Start() { if (PlayFabClientAPI.IsClientLoggedIn() == true) { PlayFabAuthenticationAPI.GetEntityToken(new GetEntityTokenRequest(), (entityResult) => { entityId = entityResult.Entity.Id; entityType = entityResult.Entity.Type; Debug.Log(entityId + entityType); LoadAllFiles(); }, OnPlayFabError); } PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest() { ProfileConstraints = new PlayerProfileViewConstraints() { ShowAvatarUrl = true } }, result => { Debug.Log("Avatar Url is : " + result.PlayerProfile.AvatarUrl); }, error => Debug.Log("Failed To Get Playfab Id")); } IEnumerator 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); } ); PlayFabClientAPI.UpdateAvatarUrl(new UpdateAvatarUrlRequest() { ImageUrl = fileData.DownloadUrl }, OnSuccess => {}, OnFailed => { }); ; Debug.Log(fileData.DownloadUrl); Debug.Log(fileData.FileName); Debug.Log(fileData.Size); UnityWebRequest www = UnityWebRequestTexture.GetTexture(fileData.DownloadUrl); yield return www.SendWebRequest(); Texture2D myTexture = DownloadHandlerTexture.GetContent(www); profilep2.sprite = Sprite.Create(myTexture, new Rect(0f, 0f, myTexture.width, myTexture.height), new Vector2(0.5f, 0.5f), 100.0f); ; }
Can you help me? Thanks.