Unity

Unity integration

Introduction

In the Game Progress module, you will be able to store game specific data related to the user progression.

Set Custom User Data

You can store your custom serialized classes in our database:

using UnityEngine;
using RGN.Modules.GameProgress;

[System.Serializable]
public class CustomUserData
{
    public int HitPoints;
    public int RegenerateHealth;
    public int HealthRegenDelay;
    public int HealthRegenRate;
    public string SomeString;
    public string[] Bookmarks;
    public float Health;
}

public class GameProgressExamples : MonoBehaviour
{
    public async void StoreCustomDataAsync()
    {
        var customData = new CustomUserData()
        {
            HitPoints = 10,
            RegenerateHealth = 10,
            HealthRegenDelay = 39,
            SomeString = "Hello World",
            Bookmarks = new string[] { "bookmark_1", "bookmark_2" },
            Health = 3.14f
        };
        UpdateUserLevelResponseData<CustomUserData> customUserData = await GameProgressModule.I.UpdateUserProgressAsync(customData, null);
        Debug.Log($"Updated hit points : "+ customUserData.playerProgress.HitPoints);
    }
}

Get Custom User Data

You can get your custom serialized classes in our database:

using UnityEngine;
using RGN.Modules.GameProgress;

[System.Serializable]
public class CustomUserData
{
    public int HitPoints;
    public int RegenerateHealth;
    public int HealthRegenDelay;
    public int HealthRegenRate;
    public string SomeString;
    public string[] Bookmarks;
    public float Health;
}

public class GameProgressExamples : MonoBehaviour
{
    public async void GetCustomDataAsync()
    {
        var customUserData = await GameProgressModule.I.GetUserProgressAsync<CustomUserData>();
        Debug.Log($"Retrieved hit points : "+ customUserData.playerProgress.HitPoints);
    }
}