Unity integration
Unreal integration
public async Task<LeaderboardData> GetLeaderboardByIdAsync(string id)public async Task<LeaderboardData> GetLeaderboardByRequestNameAsync(string requestName)using System.Collections.Generic;
using RGN.Modules.Leaderboard;
using UnityEngine;
namespace SomeNamespace
{
internal sealed class GetLeaderboards
{
public async void GetLeaderboardsAsync()
{
List<string> leaderboardIds =
await LeaderboardModule.I.GetLeaderboardIdsAsync();
for (int i = 0; i < leaderboardIds.Count; ++i)
{
Debug.Log("Leaderboard id: " + leaderboardIds[i]);
}
}
}
}using RGN.Modules.Leaderboard;
using UnityEngine;
namespace SomeNamespace
{
internal sealed class SetPlayerScore
{
public async void SetPlayerScoreAsync(string leaderboardId)
{
int playerPlace =
await LeaderboardModule.I.SetScoreAsync(leaderboardId, 42);
Debug.Log("Player place after setting the score: " +
playerPlace);
}
}
}using RGN.Modules.Leaderboard;
using UnityEngine;
namespace SomeNamespace
{
internal sealed class SetPlayerScoreWithCustomData
{
[System.Serializable]
public struct PlayerData
{
public string DisplayName;
public string Description;
public int Kills;
public int Deaths;
}
public async void SetPlayerScoreWithCustomDataAsync(
string leaderboardId,
PlayerData playerData)
{
int playerPlace = await LeaderboardModule.I.SetScoreAsync(
leaderboardId,
69,
JsonUtility.ToJson(playerData));
Debug.Log("Player place after setting the score: " +
playerPlace);
}
}
}using RGN.Modules.Leaderboard;
using UnityEngine;
namespace SomeNamespace
{
internal sealed class GetUserEntry
{
public async void GetUserEntryAsync(string leaderboardId)
{
LeaderboardEntry result =
await LeaderboardModule.I.GetUserEntryAsync(leaderboardId);
var sb = new System.Text.StringBuilder();
sb.Append("User ID: ").AppendLine(result.userId);
sb.Append("Score: ").AppendLine(result.score.ToString());
sb.Append("Formatted Score: ").AppendLine(result.formattedScore);
sb.Append("Place: ").AppendLine(result.place.ToString());
sb.Append("Extra Data: ").AppendLine(result.extraData);
Debug.Log(sb.ToString());
}
}
}using System.Collections.Generic;
using RGN.Modules.Leaderboard;
using UnityEngine;
namespace SomeNamespace
{
internal sealed class GetEntries
{
public async void GetEntriesAsync(string leaderboardId)
{
List<LeaderboardEntry> results =
await LeaderboardModule.I.GetEntriesAsync(
leaderboardId,
quantityTop: 10,
includeUser: true,
5);
for (int i = 0; i < results.Count; ++i)
{
LeaderboardEntry result = results[i];
var sb = new System.Text.StringBuilder();
sb.Append("User ID: ").AppendLine(result.userId);
sb.Append("Score: ").AppendLine(result.score.ToString());
sb.Append("Formatted Score: ").AppendLine(result.formattedScore);
sb.Append("Place: ").AppendLine(result.place.ToString());
sb.Append("Extra Data: ").AppendLine(result.extraData);
Debug.Log(sb.ToString());
}
}
}
}