Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Unity integration
Unreal Engine integration
Unity integration
"io.getready.rgn.sample": "https://github.com/readyio/RGNSample.git#0.10.0-dev.529",Unreal integration
Unreal integration
"com.unity.nuget.newtonsoft-json": "3.2.1",var result = await [module_name].I.GetSomeResultAsync();var purchaseResult = await StoreModule.I.BuyVirtualItemsAsync(itemIds);"network.theplay.unity.achievement": "https://github.com/PLAY-Network/PlayUnityAchievementPkg.git#0.16.0-dev.23",
"network.theplay.unity.analytics







https://github.com/PLAY-Network/PlayUnityAchievementPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityAnalyticsPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityCorePkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityCurrencyPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityGameProgressPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityInventoryPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityLeaderboardPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnitySignInEmailPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnitySignInGuestPkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityStorePkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityUserProfilePkg.git#0.16.0-dev.23
https://github.com/PLAY-Network/PlayUnityVirtualItemsPkg.git#0.16.0-dev.23








Integration Guide
Integration Guide
Integration Guide
Unity integration
using RGN.Modules.SignIn;
public class EmailLoginLogout : MonoBehaviour
{
public void EmailSignIn()
{
// This call will open a web form
// Handle the result in RGNCore.I.AuthenticationChanged event callback
EmailSignInModule.I.TryToSignIn();
}
public void EmailSignOut()
{
EmailSignInModule.I.SignOut();
}
}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");
}
}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}");
}
}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}");
}
}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}");
}
}
}using RGN;
using RGN.Modules.SignIn;
using UnityEngine;
public class AuthenticationChangedController : MonoBehaviour
{
private void OnEnable()
{
RGNCore.I.AuthenticationChanged += OnAuthenticationChangedAsync;
}
private void OnDisable()
{
RGNCore.I.AuthenticationChanged -= OnAuthenticationChangedAsync;
}
private async void OnAuthenticationChangedAsync(AuthState authState)
{
switch (authState.LoginState)
{
case EnumLoginState.Success:
Debug.Log("User is logged in");
// You can start retrieving some data here
break;
case EnumLoginState.NotLoggedIn:
Debug.Log("User is not logged in");
break;
case EnumLoginState.Error:
Debug.LogError("On Auth error: " + authState.LoginState +
", error: " + authState.LoginResult);
break;
default:
Debug.LogError("Unhandled Login State: " + authState.LoginState);
break;
}
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.VirtualItems;
public class VirtualItemExamples : MonoBehaviour
{
public async void GetAllVirtualItem()
{
List<VirtualItem> virtualItems = await VirtualItemsModule.I.GetVirtualItemsAsync();
foreach (var virtualItem in virtualItems)
{
Debug.Log($"Virtual item id : {virtualItem.id} \n" +
$"virtual item name : {virtualItem.name}");
// etc
}
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.VirtualItems;
public class VirtualItemExamples : MonoBehaviour
{
private List<VirtualItem> allLoadedItems = new List<VirtualItem>();
private VirtualItem lastLoadedItem = null;
public async void GetVirtualItemsPaginationAsync()
{
List<VirtualItem> virtualItems = new List<VirtualItem>();
if (allLoadedItems.Count > 0)
{
lastLoadedItem = allLoadedItems[allLoadedItems.Count - 1];
virtualItems = await VirtualItemsModule.I.GetVirtualItemsAsync(5, lastLoadedItem.id); // Get 5 more items
}
else
{
virtualItems = await VirtualItemsModule.I.GetVirtualItemsAsync(5, ""); // Get 5 first items
}
allLoadedItems.AddRange(virtualItems);
Debug.Log(allLoadedItems.Count);
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.VirtualItems;
public class VirtualItemExamples : MonoBehaviour
{
public async void GetVirtualItemsAsync()
{
List<string> tags = new List<string> { "guns", "rifles" };
List<VirtualItem> virtualItems = await VirtualItemsModule.I.GetByTagsAsync(tags);
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.VirtualItems;
public class VirtualItemExamples : MonoBehaviour
{
public async void GetByIdsAsync()
{
List<string> ids = new List<string> { "item_one_id", "item_two_id" };
List<VirtualItem> virtualItems = await VirtualItemsModule.I.GetVirtualItemsByIdsAsync(ids);
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.VirtualItems;
public class VirtualItemExamples : MonoBehaviour
{
public async void UpdateVirtualItemInfosAsync()
{
string virtualItemId = "some_virtual_item";
await VirtualItemsModule.I.SetNameAsync(virtualItemId, "New Virtual Item Name");
await VirtualItemsModule.I.SetDescriptionAsync(virtualItemId, "New Virtual Item Description");
List<string> newTags = new List<string> { "tag01", "tag02" };
await VirtualItemsModule.I.SetTagsAsync(virtualItemId, newTags);
}
}using UnityEngine;
using RGN.Modules.VirtualItems;
[System.Serializable]
public struct MyCustomVirtualItemData
{
public int MyInt;
public string MyString;
public float MyFloat;
}
public class VirtualItemExamples : MonoBehaviour
{
public async void UpdatePropertiesAsync()
{
string virtualItemId = "some_virtual_item";
var myCustomData = new MyCustomVirtualItemData()
{
MyFloat = 42.78f,
MyInt = 51,
MyString = "Hello World"
};
string propertiesJson = JsonUtility.ToJson(myCustomData);
await VirtualItemsModule.I.SetPropertiesAsync(virtualItemId, propertiesJson);
}
public async void GetPropertiesAsync()
{
string virtualItemId = "some_virtual_item";
var jsonProperties = await VirtualItemsModule.I.GetPropertiesAsync(virtualItemId);
MyCustomVirtualItemData myCustomData = JsonUtility.FromJson<MyCustomVirtualItemData>(jsonProperties);
Debug.Log(myCustomData.MyString);
}
}using UnityEngine;
using RGN.Modules.VirtualItems;
public class VirtualItemExamples : MonoBehaviour
{
public async void UpdateVirtualItemImageAsync(string virtualItemId, Texture2D virtualItemImage)
{
byte[] bytes = virtualItemImage.EncodeToPNG();
await VirtualItemsModule.I.UploadImageAsync(virtualItemId,bytes);
}
}using UnityEngine;
using RGN.Modules.VirtualItems;
using RGN.Model;
using System.Threading.Tasks;
public class VirtualItemExamples : MonoBehaviour
{
public async Task<Texture2D> DownloadVirtualItemImageAsync(string virtualItemId)
{
byte[] bytes = await VirtualItemsModule.I.DownloadImageAsync(virtualItemId, ImageSize.Small);
Texture2D resultTexture = new Texture2D(1, 1);
resultTexture.LoadImage(bytes);
resultTexture.Apply();
return resultTexture;
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Inventory;
public class InventoryExamples : MonoBehaviour
{
private async void GetUserInventory()
{
List<InventoryItemData> inventory = await InventoryModule.I.GetWithVirtualItemsDataForCurrentAppAsync();
foreach (var inventoryItem in inventory)
{
Debug.Log($"Virtual item id : {inventoryItem.virtualItemId}");
Debug.Log($"Virtual item name : {inventoryItem.virtualItem.name}");
}
}
}using UnityEngine;
using RGN.Modules.Inventory;
public class InventoryExamples : MonoBehaviour
{
private async void AddToUserInventory()
{
string virtualItemId = "virtualItemToAdd";
await InventoryModule.I.AddToInventoryAsync(virtualItemId);
}
}using UnityEngine;
using RGN.Modules.Inventory;
public struct MyCustomProperties
{
public int BonusHealth;
public float DamageMultiplier;
}
public class InventoryExamples : MonoBehaviour
{
private async void SetPropertiesInInventory()
{
string inventoryItemId = "inventoryItemId";
MyCustomProperties customProperties = new MyCustomProperties
{
BonusHealth = 50,
DamageMultiplier = 1.5f
};
string jsonProperties = JsonUtility.ToJson(customProperties);
await InventoryModule.I.SetPropertiesAsync(inventoryItemId, jsonProperties);
}
}using UnityEngine;
using RGN.Modules.Inventory;
public struct MyCustomProperties
{
public int BonusHealth;
public float DamageMultiplier;
}
public class InventoryExamples : MonoBehaviour
{
private async void GetPropertiesInInventory()
{
string inventoryItemId = "inventoryItemId";
string jsonProperties = await InventoryModule.I.GetPropertiesAsync(inventoryItemId);
MyCustomProperties customProperties = JsonUtility.FromJson<MyCustomProperties>(jsonProperties);
Debug.Log($"Bonus health : {customProperties.BonusHealth} \n" +
$"Damage multiplier : {customProperties.DamageMultiplier}");
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Store;
using RGN.Modules.VirtualItems;
using RGN.Modules.Currency;
using RGN.Modules.Inventory;
public class StoreExamples : MonoBehaviour
{
public async void BuyVirtualItemAsync(VirtualItem virtualItem)
{
List<string> itemsToPurchase = new List<string>() { virtualItem.id };
PurchaseResult purchaseResult = await StoreModule.I.BuyVirtualItemsAsync(itemsToPurchase);
// purchaseResult returns the purchased items and updated currencies
List<Currency> updatedCurrencies = purchaseResult.updatedCurrencies;
List<InventoryItemData> purchasedItems = purchaseResult.items;
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Store;
using RGN.Modules.Currency;
using RGN.Modules.Inventory;
public class StoreExamples : MonoBehaviour
{
public async void BuyStoreOfferAsync()
{
PurchaseResult purchaseResult = await StoreModule.I.BuyStoreOfferAsync("storeOfferId");
// purchaseResult Returns the purchased items and updated currencies
List<Currency> updatedCurrencies = purchaseResult.updatedCurrencies;
List<InventoryItemData> purchasedItems = purchaseResult.items;
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Store;
public class StoreExamples : MonoBehaviour
{
public async void GetStoreOfferAsync()
{
// Get the first 10 offer
List<StoreOffer> offers = await StoreModule.I.GetWithVirtualItemsDataForCurrentAppAsync(10);
// Pick the first returned offer for log purposes
StoreOffer firstStoreOffer = offers[0];
Debug.Log($"Store offer id : {firstStoreOffer.id}");
// Log the virtuals items name for this offer
foreach (var virtualItem in firstStoreOffer.virtualItems)
{
Debug.Log($"Virtual item name : {virtualItem.name}");
}
}
}using System.Collections.Generic;
using UnityEngine;
using RGN;
using RGN.Modules.Wallets;
using RGN.Modules.SignIn;
using RGN.Modules.Store;
public class NFTPurchaseExamples : MonoBehaviour
{
private async void BuyNFTVirtualItem()
{
bool authWithEmail = RGNCoreBuilder.I.CurrentAuthState.AuthProvider == EnumAuthProvider.Email;
if (!authWithEmail)
{
EmailSignInModule.I.TryToSignIn();
return;
}
bool hasBlockchainRequirement = await WalletsModule.I.IsUserHasBlockchainRequirementAsync();
if (!hasBlockchainRequirement)
{
WalletsModule.I.CreateWallet();
return;
}
List<string> virtualItemIds = new List<string> { "myNftVirtualItemId" };
PurchaseResult purchaseResult = await StoreModule.I.BuyVirtualItemsAsync(virtualItemIds);
}
}
Integration Guide
Unreal integration
Unreal integration
Unity integration
Integration Guide
Guides on Player-Facing Implementation of PLAY Modules
Unreal integration
Integration Guide
Unreal integration
Integration Guide
Integration Guide
Integration guide
Integration guide
Unreal integration
Unreal integration
using UnityEngine;
using RGN;
public class WalletExamples : MonoBehaviour
{
private bool IsUserAuthenticatedWithEmail()
{
return RGNCoreBuilder.I.CurrentAuthState.AuthProvider == EnumAuthProvider.Email;
}
}using UnityEngine;
using RGN;
using RGN.Modules.Wallets;
using System.Threading.Tasks;
public class WalletExamples : MonoBehaviour
{
private async Task<bool> IsUserHasBlockchainRequirement()
{
bool hasRequirement = await WalletsModule.I.IsUserHasBlockchainRequirementAsync();
return hasRequirement;
}
}using UnityEngine;
using RGN.Modules.Wallets;
public class WalletExamples : MonoBehaviour
{
private void CreateWallet()
{
// This will open the OAuth form for the wallet creation
WalletsModule.I.CreateWallet();
}
{using System.Collections.Generic;
using UnityEngine;
using RGN;
using RGN.Modules.Wallets;
using RGN.Modules.SignIn;
using RGN.Modules.Store;
public class WalletExamples : MonoBehaviour
{
private async void BuyNFTVirtualItem()
{
bool authWithEmail = RGNCoreBuilder.I.CurrentAuthState.AuthProvider == EnumAuthProvider.Email;
if (!authWithEmail)
{
EmailSignInModule.I.TryToSignIn();
return;
}
bool hasBlockchainRequirement = await WalletsModule.I.IsUserHasBlockchainRequirementAsync();
if (!hasBlockchainRequirement)
{
WalletsModule.I.CreateWallet();
return;
}
List<string> virtualItemIds = new List<string> { "myNftVirtualItemId" };
PurchaseResult purchaseResult = await StoreModule.I.BuyVirtualItemsAsync(virtualItemIds);
}
}Unity integration
Integration Guide
ParticipateInMatchAsync()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);
}
}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());
}
}
}
}try
{
// Create a match configuration
MatchmakingData matchConfig = new MatchmakingData
{
// fill matchConfig details
};
// Create optional participation payload
Dictionary<string, object> participatePayload = new Dictionary<string, object>
{
{"ExtraData1", "Value1"},
{"ExtraData2", "Value2"}
};
// Call the CreateMatchAsync method
var matchmakingResult = await MatchmakingModule.I.CreateMatchAsync(
matchConfig,
true,
participatePayload);
}
catch (ArgumentNullException ex)
{
Debug.Log("MatchConfig is null: " + ex.Message);
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the match ID
string matchId = "your_match_id";
// Create optional participant payload
Dictionary<string, object> participantPayload = new Dictionary<string, object>
{
{"ExtraData1", "Value1"},
{"ExtraData2", "Value2"}
};
// Call the ParticipateInMatchAsync method
string participatedMatchId = await MatchmakingModule.I.ParticipateInMatchAsync(
matchId,
participantPayload);
// Use the participatedMatchId in your game logic
// ...
}
catch (ArgumentNullException ex)
{
Debug.Log("MatchId is null or empty: " + ex.Message);
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the match ID
string matchId = "your_match_id";
// Call the StartMatchAsync method
string startedMatchId = await MatchmakingModule.I.StartMatchAsync(matchId);
// Use the startedMatchId in your game logic
// ...
}
catch (ArgumentNullException ex)
{
Debug.Log("MatchId is null or empty: " + ex.Message);
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the match ID and participant ID
string matchId = "your_match_id";
string participantId = "your_participant_id";
// Call the VoteForMatchAsync method
string votedMatchId = await MatchmakingModule.I.VoteForMatchAsync(
matchId,
participantId);
// Use the votedMatchId in your game logic
// ...
}
catch (ArgumentNullException ex)
{
Debug.Log("MatchId or ParticipantId is null or empty: " + ex.Message);
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the match ID and score
string matchId = "your_match_id";
long score = 10000; // your score
// Call the SubmitMatchScoreAsync method
string submittedScoreMatchId = await MatchmakingModule.I.SubmitMatchScoreAsync(
matchId,
score);
// Use the submittedScoreMatchId in your game logic
// ...
}
catch (ArgumentNullException ex)
{
Debug.Log("MatchId is null or empty: " + ex.Message);
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the match ID
string matchId = "your_match_id";
// Call the FinishMatchAsync method
string finishedMatchId = await MatchmakingModule.I.FinishMatchAsync(matchId);
// Use the finishedMatchId in your game logic
// ...
}
catch (ArgumentNullException ex)
{
Debug.Log("MatchId is null or empty: " + ex.Message);
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the limit and optionally the startAfter match ID
int limit = 10;
string startAfter = "some_match_id"; // Or leave empty for the default value
// Call the GetJoinOpenMatchesAsync method
List<MatchmakingData> openMatches =
await MatchmakingModule.I.GetJoinOpenMatchesAsync(limit, startAfter);
// Iterate over the openMatches and use in your game logic
foreach (MatchmakingData match in openMatches)
{
// Your game logic here
// ...
}
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the limit and optionally the startAfter match ID
int limit = 10;
string startAfter = "some_match_id"; // Or leave empty for the default value
// Call the GetVoteOpenMatchesAsync method
List<MatchmakingData> openVoteMatches =
await MatchmakingModule.I.GetVoteOpenMatchesAsync(limit, startAfter);
// Iterate over the openVoteMatches and use in your game logic
foreach (MatchmakingData match in openVoteMatches)
{
// Your game logic here
// ...
}
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the limit and optionally the startAfter match ID
int limit = 10;
string startAfter = "some_match_id"; // Or leave empty for the default value
// Call the GetFinishedMatchesAsync method
List<MatchmakingData> finishedMatches =
await MatchmakingModule.I.GetFinishedMatchesAsync(limit, startAfter);
// Iterate over the finishedMatches and use in your game logic
foreach (MatchmakingData match in finishedMatches)
{
// Your game logic here
// ...
}
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}try
{
// Define the match ID
string matchId = "some_match_id";
// Call the GetFinishedMatchByIdAsync method
MatchmakingData finishedMatch =
await MatchmakingModule.I.GetFinishedMatchByIdAsync(matchId);
// Use the finishedMatch in your game logic
// ...
}
catch (OperationCanceledException ex)
{
Debug.Log("Operation was cancelled: " + ex.Message);
}
catch (Exception ex)
{
Debug.Log("Failed to get the match: " + ex.Message);
}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);
}
}
using UnityEngine;
using RGN.Modules.Messaging;
public class MessagingExamples : MonoBehaviour, IMessageReceiver
{
private void Start()
{
// TODO: use module constants for topic parameter, for example:
// RGN.Modules.Inventory.InventoryModule.ITEM_ADDED_EVENT_TOPIC
MessagingModule.I.Subscribe("it_is_better_to_use_module_constants", this);
}
private void OnDestroy()
{
MessagingModule.I.Unsubscribe("it_is_better_to_use_module_constants", this);
}
public void OnMessageReceived(string topic, Message message)
{
Debug.Log($"New message received for topic : {topic}, message : {message}");
}
}using UnityEngine;
using RGN.Modules.Achievement;
using System.Collections.Generic;
public class AchievementExamples : MonoBehaviour
{
private async void GetAllGameAchievements()
{
// Retrieves the 10 first achievements setup for my game
List<AchievementData> achievements = await AchievementsModule.I.GetForCurrentAppAsync(10);
foreach (var achievement in achievements)
{
Debug.Log($"Achievement name : {achievement.name} \n" +
$"Description : {achievement.description}");
}
}
}using UnityEngine;
using RGN.Modules.Achievement;
using System.Collections.Generic;
public class AchievementExamples : MonoBehaviour
{
private async void GetUserAchievementsAsync()
{
List<AchievementWithUserData> achievements = await AchievementsModule.I.GetForCurrentAppWithUserDataAsync(10);
foreach (var achievement in achievements)
{
UserAchievement userAchievement = achievement.GetUserAchievement();
Debug.Log($"Achievement name : {achievement.name} \n" +
$"Achievement progression : {userAchievement.value}/{achievement.valueToReach}");
}
}
}using UnityEngine;
using RGN.Modules.Achievement;
public class AchievementExamples : MonoBehaviour
{
private async void CompleteAchievementAsync()
{
await AchievementsModule.I.TriggerByIdAsync("myAchievementId");
// This will increase the achievement progression by 1
// An additionnal parameter can be passed to increase the progress amount
}
}using UnityEngine;
using RGN.Modules.Achievement;
public class AchievementExamples : MonoBehaviour
{
private async void CompleteAchievementAsync()
{
await AchievementsModule.I.TriggerByRequestNameAsync("myRequestName");
// This will increase the achievement progression by 1
// An additionnal parameter can be passed to increase the progress amount
}
}using UnityEngine;
using RGN.Modules.Achievement;
using System.Collections.Generic;
public class AchievementExamples : MonoBehaviour
{
private async void ClaimAchievementAsync()
{
var result = await AchievementsModule.I.ClaimByIdAsync("achievementId");
List<AchievementReward> rewards = result.rewards;
foreach (var reward in rewards)
{
Debug.Log($"Reward name : {reward.name} \n" +
$"Reward type : {reward.type} \n" +
$"Reward quantity : {reward.quantity}");
}
}
}using UnityEngine;
using RGN.Modules.Achievement;
using System.Collections.Generic;
public class AchievementExamples : MonoBehaviour
{
private async void ClaimAchievementAsync()
{
var result = await AchievementsModule.I.ClaimByRequestNameAsync("myRequestName");
List<AchievementReward> rewards = result.rewards;
foreach (var reward in rewards)
{
Debug.Log($"Reward name : {reward.name} \n" +
$"Reward type : {reward.type} \n" +
$"Reward quantity : {reward.quantity}");
}
}
}"uid": "4a13bcd3-ff64-43a4-8c13-e978d968f68c",
"priceInUSD": 0.99,
"quantity": 10"uid": "0eeae85c-c9af-47f0-8df4-56a4442c23d7",
"priceInUSD": 1.99,
"quantity": 20"uid": "9d2ed68b-2a6c-45d4-bc07-29f256799943",
"priceInUSD": 2.99,
"quantity": 30"uid": "b7bcbbf6-753d-47dd-8bff-93b4539c825d",
"priceInUSD": 4.99,
"quantity": 50"uid": "b81e8e95-59a6-4a77-b1bc-f5b7d6eacfa4",
"priceInUSD": 9.99,
"quantity": 110"uid": "f35c4f83-cf22-4723-828a-66e8069614eb",
"priceInUSD"
"uid": "3c814835-9f6f-4947-98f0-6e70964b887d",
"priceInUSD"
"uid": "b65994dc-ecfd-4549-ab32-51e196947c8b",
"priceInUSD"
"uid": "4a13bcd3-ff64-43a4-8c13-e978d968f68c",
"priceInUSD": 0.99,
"quantity": 10"uid": "0eeae85c-c9af-47f0-8df4-56a4442c23d7",
"priceInUSD": 1.99,
"quantity": 20"uid": "9d2ed68b-2a6c-45d4-bc07-29f256799943",
"priceInUSD": 2.99,
"quantity": 30"uid": "b7bcbbf6-753d-47dd-8bff-93b4539c825d",
"priceInUSD": 4.99,
"quantity": 50"uid": "b81e8e95-59a6-4a77-b1bc-f5b7d6eacfa4",
"priceInUSD": 9.99,
"quantity": 110"uid": "f35c4f83-cf22-4723-828a-66e8069614eb",
"priceInUSD"
"uid": "3c814835-9f6f-4947-98f0-6e70964b887d",
"priceInUSD"
"uid": "b65994dc-ecfd-4549-ab32-51e196947c8b",
"priceInUSD"
using UnityEngine;
using RGN.Modules.Currency;
using UnityEngine.Purchasing;
public class CurrenciesExamples : MonoBehaviour
{
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
{
bool validPurchase = true; // Presume valid for platforms with no R.V.
if (validPurchase)
{
Debug.Log($"Product {purchaseEvent.purchasedProduct.definition.id} Purchased");
string transactionId = purchaseEvent.purchasedProduct.transactionID;
string receipt = purchaseEvent.purchasedProduct.receipt;
PurchaseRGNCoinAsync(transactionId, receipt);
}
else
{
Debug.LogError($"Something happened when trying to purchase product {purchaseEvent.purchasedProduct.definition.id}");
}
return PurchaseProcessingResult.Complete;
}
public async void PurchaseRGNCoinAsync(string transactionId, string receipt)
{
string rgnProductId = "4a13bcd3-ff64-43a4-8c13-e978d968f68c"; // 10 rgn-coin
await CurrencyModule.I.PurchaseRGNCoinAsync(rgnProductId, transactionId, receipt);
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Currency;
public class CurrenciesExamples : MonoBehaviour
{
public async void GetRgnCoinCurrenciesAsync()
{
List<Currency> currencies = await CurrencyModule.I.GetUserCurrenciesAsync();
Currency readyCurrency = currencies.Find(x => x.name.Equals("rgn-coin"));
Debug.Log($"User has {readyCurrency.quantity} rgn-coin");
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Currency;
public class CurrenciesExamples : MonoBehaviour
{
public async void AddSoftCurrenciesAsync()
{
Currency goldCurrency = new Currency
{
name = "gold",
quantity = 10
};
List<Currency> currenciesToAdd = new List<Currency> { goldCurrency };
await CurrencyModule.I.AddUserCurrenciesAsync(currenciesToAdd);
}
}using System.Collections.Generic;
using UnityEngine;
using RGN.Modules.Currency;
public class CurrenciesExamples : MonoBehaviour
{
public async void GetSoftCurrenciesAsync()
{
List<Currency> currencies = await CurrencyModule.I.GetUserCurrenciesAsync();
Currency goldCurrency = currencies.Find(x => x.name.Equals("gold"));
Debug.Log($"User has {goldCurrency.quantity} gold");
}
}











