Comment on page
User Profile
Integration Guide
There are 3 user profile data types you can get from the backend.
using System;
namespace RGN.Modules.UserProfile
{
[Serializable]
public class UserData
{
public string userId;
public string shortUID;
public string displayName = "";
public string bio;
}
}
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 = new List<Currency.Currency>();
public bool isCreator;
public string brandName;
public byte[] profilePictureBytes;
public int GetRGNCoinBalance();
public int GetCustomCoinBalance(string currencyName);
}
}
using RGN.Modules.UserProfile;
using System;
namespace RGN.Modules.GameProgress
{
[Serializable]
public class GameUserFullProfileData : UserProfileData
{
public int readyWins;
public int readyLosses;
public int readyDraws;
public int readyTrophies;
public int readyAchievements;
public int previousThreshold;
public int nextThreshold;
}
}
You can see from the code snippets that
UserProfileData
inherits UserData
. And the GameUserFullProfileData
inherits UserProfileData
. It means the GameUserFullProfileData
contains all fields from other classes. So, in case you need the full profile with user currrencies information, you can get it by calling await UserProfileModule.I.GetFullUserProfileAsync<
UserProfileData>(userId);
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);
}
}
}
}
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);
}
}
}
using RGN.Modules.UserProfile;
namespace SomeNamespace
{
internal sealed class UpdateUserName
{
public async void UpdateDisplayNameAsync(string displayName)
{
await UserProfileModule.I.SetDisplayNameAsync(displayName);
}
}
}
using RGN.Modules.UserProfile;
namespace SomeNamespace
{
internal sealed class UpdateUserBio
{
public async void UpdateBioAsync(string bio)
{
await UserProfileModule.I.SetBioAsync(bio);
}
}
}
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);
}
}
}
}
Similar to other in-game currencies but it can only be obtained by making In-App Purchases - it cannot be earned or given as a reward to players. It is consumed to purchase NFT or Non-NFT virtual-items.
In order to buy
rgn-coin
follow details at 4.-purchase-rgn-coin-iap