Unity
Unity integration
Introduction
The users can buy Virtual Items either individually or in packs. After a virtual item is purchased it will be added to the user's inventory. You can use the PLAY Dev Dashboard to create new store offers and virtual items.
Each store offer can contain one or more virtual items to sell. Price info data is also part of the store offer. It is also possible to sell virtual items without creating store offers.
Buy Virtual Items and Store offers
In case the virtual item contains prices information
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;
}
}Purchase from store offer
Get store offer
Buy Virtual Items NFT
In order to purchase NFTs, there is some additional check you will need to do to make sure the user has all the requirements. Here's an example:
Last updated
Was this helpful?