Hello, I am using playfab and photon plugin in my game. I can login with Playfab without any problem. In the main menu of my game, there is a user-specific panel with the user picture and username in the upper right corner. I can show the username on the panel and map it to the photon without a problem. Additionally, with a plugin, I allow users to select a profile photo from the phone gallery at login. I can show this user-selected photo on the panel in the main menu. But I want this photo to be specific to the user who is logged in with playfab, I want to show this photo next to the usernames in the rooms where the photon and usernames are listed. Is it possible? Can you guide me, what should I do? I am sharing the link of the plugin I mentioned and the code file I used.
The second code file is the code file of the prefab converted game object containing the username of the users joining the room.
https://github.com/yasirkula/UnityNativeGallery
using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.UI; using PlayFab; using PlayFab.ClientModels; using System; using System.IO; public class PlayFabManager : MonoBehaviour { [Header("UI")] public Text messageText,isim ; public InputField usernameInput; public InputField emailInput; public InputField passwordInput; public GameObject Panel public Image profilepicture; private string Email; private string Username; private string Password; private PlayFabAuthService _AuthService = PlayFabAuthService.Instance; public void profılepıcture() { GaleridenResimCek( 1024 ); } private void GaleridenResimCek( int maksimumBuyukluk ) { NativeGallery.Permission izin = NativeGallery.GetImageFromGallery( ( konum ) => { Debug.Log( "Seçilen resmin konumu: " + konum ); if( konum != null ) { 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; } profilepicture.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 ); } public void RegisterButton() { if (passwordInput.text.Length < 6) { messageText.text = "Şifreniz en az 6 karakter içermelidir!"; return; } if (usernameInput.text.Length < 6) { messageText.text = "Kullanıcı Adı 3-20 Karakter Arası Olmalıdır!"; return; } var request = new RegisterPlayFabUserRequest { Email = emailInput.text, Password = passwordInput.text, Username = usernameInput.text, RequireBothUsernameAndEmail = true }; PlayFabClientAPI.RegisterPlayFabUser(request, OnRegisterSuccess, OnError); } void OnRegisterSuccess(RegisterPlayFabUserResult result) { messageText.text = "Kayıt Yapıldı, Giriş Yapabilirsiniz"; Username = PlayerPrefs.GetString("Username"); Password = PlayerPrefs.GetString("Password"); PlayerPrefs.Save(); } void OnError(PlayFabError error) { switch (error.Error) { case PlayFabErrorCode.InvalidEmailAddress: case PlayFabErrorCode.InvalidPassword: case PlayFabErrorCode.InvalidEmailOrPassword: messageText.text = "Geçersiz Şifre/Kullanıcı Adı/Email"; break; case PlayFabErrorCode.UnknownError: messageText.text = "İnternet Bağlantınızı Kontrol Edin Ve Uygulamayı Yeniden Başlatın"; break; case PlayFabErrorCode.InvalidAccount: case PlayFabErrorCode.InvalidUsername: messageText.text = "Geçersiz"; break; } messageText.text = error.ErrorMessage; Debug.Log(error.GenerateErrorReport()); } public void LoginButton() { PlayFabClientAPI.LoginWithPlayFab(new LoginWithPlayFabRequest { Username = "xxx", Password = "123456", InfoRequestParameters = new GetPlayerCombinedInfoRequestParams { GetUserAccountInfo = true } }, result => { isim.text = result.InfoResultPayload.AccountInfo.Username; }, error => { Debug.LogError(error.GenerateErrorReport()); }); var request = new LoginWithPlayFabRequest { Password = passwordInput.text, Username = usernameInput.text }; PlayFabClientAPI.LoginWithPlayFab(request, OnLoginSuccess, OnError); PlayerPrefs.SetString("Username", usernameInput.text); PlayerPrefs.SetString("Password", passwordInput.text); PlayerPrefs.Save(); } public void ResetPasswordButton() { var request = new SendAccountRecoveryEmailRequest { Email = emailInput.text, TitleId = "xxxx" }; PlayFabClientAPI.SendAccountRecoveryEmail(request, OnPasswordReset, OnError); } private void OnPasswordReset(SendAccountRecoveryEmailResult result) { messageText.text = "Şifre Sıfırlama Bağlantısı Mail Adresinize Gönderildi"; } void OnLoginSuccess(LoginResult result) { Debug.LogFormat("Logged In as: {0}", result.PlayFabId); messageText.text = "Giriş Yapıldı"; Debug.Log("Giriş Başarılı"); isim.text = Username; Panel.SetActive(false); } void Login() { if (Username ==string.Empty && Password == string.Empty) { Debug.Log("Kutucuklar Boş"); } else { Debug.Log("Zaten Giriş Yapıldı"); var request = new LoginWithPlayFabRequest { Password = Password, Username = Username }; PlayFabClientAPI.LoginWithPlayFab(request, OnLoginSuccess, OnError); } } void Start() { if (File.Exists(Application.persistentDataPath + "/SavedImage.png")) { Texture2D texture = NativeGallery.LoadImageAtPath(Application.persistentDataPath + "/SavedImage.png", 1024); profilepicture.sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); ; } _AuthService.InfoRequestParams = InfoRequestParams; Username = PlayerPrefs.GetString("Username"); Password = PlayerPrefs.GetString("Password"); Login(); } }
using Photon.Pun; using Photon.Realtime; using System.Collections; using System.Collections.Generic; using System; using UnityEngine; using UnityEngine.UI; public class playerlistprefab : MonoBehaviourPunCallbacks { [SerializeField] private Text _text; [SerializeField] private string nickName; public Player Player { get; private set; } public void SetPlayerInfo(Player player) { Player = player; _text.text = player.NickName; } private void Awake() { nickName = PlayerPrefs.GetString("Username"); } }