# Unity

## Introduction

The user profile module is used to store user specific data related to his identity.&#x20;

<details>

<summary>UserProfileData</summary>

* **userId** (string): *Unique READYgg ID for a user. Authenticated user has the same ID accross applications using READYgg.*
* **email** (string): *Email of the authenticated user.*
* **displayName** (string): *Authenticated user share the same display name accross applications using READYgg.*
* **profilePicture** (userProfilePicture): *Authenticated user share the same profile picture accross applications using READYgg.*
* **bio** (string): *Authenticated user share the same bio accross applications using READYgg.*
* **currencies** (List\<Currency>): *Contains all the currencies user collected for your application.*

</details>

#### UserProfileData class methods

* **GetRGNCoinBalance();**&#x20;
  * *Return the amount of rgn-coin for this user.*
* **GetCustomCoinBalance(string currencyName);**&#x20;
  * *Return the amount of your custom currency for this user.*

### **Load User Profile** <a href="#load-user-profile" id="load-user-profile"></a>

```csharp
using RGN;
using RGN.Modules.UserProfile;
using UnityEngine;

public class UserProfileExample : MonoBehaviour
{
    public async void LoadUserProfileDataAsync()
    {
        string userId = RGNCore.I.MasterAppUser.UserId;
        UserProfileData userProfileData = await UserProfileModule.I.GetFullUserProfileAsync<UserProfileData>();
        Debug.Log($"Display name : {userProfileData.displayName} \n" +
            $"Bio : {userProfileData.bio} \n" +
            $"Email : {userProfileData.email} \n");
    }
}
```

### Update UserName/Display Name

```csharp
using UnityEngine;
using RGN.Modules.UserProfile;

public class UserProfileExamples : MonoBehaviour
{
    private async void UpdateDisplayName()
    {
        string newDisplayName = await UserProfileModule.I.SetDisplayNameAsync("New display name");
        Debug.Log($"Display name : {newDisplayName}");
    }
}
```

### Update User Bio

```csharp
using UnityEngine;
using RGN.Modules.UserProfile;

public class UserProfileExamples : MonoBehaviour
{
    private async void UpdateUserBio()
    {
        string newBio = await UserProfileModule.I.SetBioAsync("This is my user description");
        Debug.Log($"Bio : {newBio}");
    }
}
```

### **Retrieve User Currencies**

```csharp
using UnityEngine;
using System.Collections.Generic;
using RGN.Modules.UserProfile;
using RGN.Modules.Currency;

public class UserProfileExamples : MonoBehaviour
{
    private async void GetUserCurrencies()
    {
        List<Currency> currencies = await UserProfileModule.I.GetUserCurrenciesAsync();
        foreach (Currency currency in currencies)
        {
            Debug.Log($"Type : {currency.name} Quantity : {currency.quantity}");
        }
    }
}
```

### "rgn-coin" Currency&#x20;

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 [#virtual-items](https://playnetwork.gitbook.io/play-sdk-documentation/virtual-items#virtual-items "mention").\
\
For more details about the rgn-coin, please refer to the [Currency module](https://playnetwork.gitbook.io/play-sdk-documentation/sdk-integration-guides/currency-iap).&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://playnetwork.gitbook.io/play-sdk-documentation/sdk-integration-guides/user-profile/unity.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
