There are 3 user profile data types you can get from the backend.
Copy using System ;
namespace RGN . Modules . UserProfile
{
[ Serializable ]
public class UserData
{
public string userId;
public string email;
public string displayName;
public UserProfilePicture profilePicture;
public string bio;
}
}
Copy using System ;
using System . Collections . Generic ;
using RGN . Utility ;
namespace RGN . Modules . UserProfile
{
[ Serializable ]
public class UserProfileData : UserData
{
public string lastAppPackageName;
public bool invisibleStatus;
public List < Currency . Currency > currencies;
public UserProfileData ()
{
currencies = new List < Currency . Currency >();
}
public int GetRGNCoinBalance ();
public int GetCustomCoinBalance ( string currencyName);
}
}
Get the user full profile data
Copy using System . IO ;
using RGN ;
using RGN . Model ;
using RGN . Modules . GameProgress ;
using RGN . Modules . UserProfile ;
using UnityEngine ;
namespace SomeNamespace
{
internal sealed class LoadUserProfile
{
public async void LoadUserProfileDataAsync ()
{
string userId = RGNCore . I . MasterAppUser . UserId ;
GameUserFullProfileData currentUserData =
await UserProfileModule . I . GetFullUserProfileAsync < GameUserFullProfileData >(userId);
}
public async void DownloadAndCacheUserAvatarAsync ()
{
string userId = RGNCore . I . MasterAppUser . UserId ;
byte [] bytes = await UserProfileModule . I . DownloadAvatarImageAsync (userId , ImageSize . Small );
if (bytes != null )
{
Texture2D avatar = new Texture2D ( 1 , 1 );
avatar . LoadImage (bytes);
avatar . Apply ();
string avatarSavePath = Path . Combine ( Application . dataPath , "user_avatars" , userId + ".png" );
File . WriteAllBytes (avatarSavePath , bytes);
}
}
}
}
Copy using RGN . Modules . UserProfile ;
using UnityEngine ;
namespace SomeNamespace
{
internal sealed class UpdateUserAvatarImage
{
public async void UpdateUserAvatarAsync ( UnityEngine . Texture2D avatarTexture)
{
byte [] bytes = avatarTexture . EncodeToPNG ();
bool success = await UserProfileModule . I . UploadAvatarImageAsync (bytes);
}
}
}
Update UserName/Display Name
Copy using RGN . Modules . UserProfile ;
namespace SomeNamespace
{
internal sealed class UpdateUserName
{
public async void UpdateDisplayNameAsync ( string displayName)
{
await UserProfileModule . I . SetDisplayNameAsync (displayName);
}
}
}
Copy using RGN . Modules . UserProfile ;
namespace SomeNamespace
{
internal sealed class UpdateUserBio
{
public async void UpdateBioAsync ( string bio)
{
await UserProfileModule . I . SetBioAsync (bio);
}
}
}
Copy using System . Collections . Generic ;
using RGN . Modules . Currency ;
using RGN . Modules . UserProfile ;
namespace SomeNamespace
{
internal sealed class RetrieveUserCurrencies
{
public async void GetUserCurrenciesAsync ()
{
List < Currency > currencies = await UserProfileModule . I . GetUserCurrenciesAsync ();
foreach ( Currency currency in currencies)
{
UnityEngine . Debug . Log ( currency . name + currency . quantity );
}
}
}
}