- Home /
Viewing Profile Photos of Users in Photon Rooms
In my project where Playfab and photon are integrated, users initially select their profile photo and upload it to Playfab Entity Files. Later, when they enter a room in the lobby, they download the photo they uploaded. However, the user sees the photo of all the players in the room as his own photo on his phone. So it downloads the same photo 4 times. Each user downloads their own photo 4 times on their own screen and can only see their own photo. How can users see their own photo of other users in the room, where am I going wrong? To upload the user's profile picture :
private void ChooseImage(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");
Debug.Log("İzin durumu: " + izin);
}
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 image I uploaded :
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);
}
}
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); ;
}
Your answer
Follow this Question
Related Questions
Correct way to design turn based multiplayer using Photon Unity Networking. 0 Answers
uNet like photon 0 Answers
How to network a large map with 4000+ movable objects using Photon Unity Networking? 1 Answer
Pun In Room Chat Script 1 Answer
Photon: I call PhotonNetwork.LeaveRoom() but my character doesn't leave 1 Answer