Skip to content

Implement an In-Game Store

This how-to lists Catalog items grouped by kind and converts them into the data your UI needs to build an in-game store.

Prerequisites

Get the Catalog Items

To build the store UI, first gather all the information about what you're selling.

private void CreateStoreUI()
{
string CatalogKey = "<INSERT KEY>";
int count = 0;
string after = null;
LootLockerSDKManager.ListCatalogItems(CatalogKey, count, after, (response) =>
{
if (!response.success)
{
Debug.Log("Could not List Items from Catalog");
return;
}
LootLockerInlinedCatalogEntry[] inlinedEntryList = response.GetLootLockerInlinedCatalogEntries();
foreach (var entry in inlinedEntryList)
{
switch (entry.entity_kind)
{
case LootLockerCatalogEntryEntityKind.asset:
ConfigureAsset(entry.asset_details);
break;
case LootLockerCatalogEntryEntityKind.currency:
ConfigureCurrency(entry.currency_details);
break;
case LootLockerCatalogEntryEntityKind.progression_points:
ConfigureProgressionPoints(entry.progression_point_details);
break;
case LootLockerCatalogEntryEntityKind.progression_reset:
ConfigureProgressionReset(entry.progression_reset_details);
break;
case LootLockerCatalogEntryEntityKind.group:
ConfigureGroup(entry.group_details);
break;
}
}
});
}
private void ConfigureAsset(LootLockerAssetDetails asset)
{
Debug.Log(asset.name);
Debug.Log(asset.id);
Debug.Log(asset.thumbnail);
}
private void ConfigureCurrency(LootLockerCurrencyDetails currency)
{
Debug.Log(currency.amount);
Debug.Log(currency.name);
Debug.Log(currency.id);
Debug.Log(currency.code);
}
private void ConfigureProgressionPoints(LootLockerProgressionPointDetails progression)
{
Debug.Log(progression.amount);
Debug.Log(progression.name);
Debug.Log(progression.id);
Debug.Log(progression.key);
}
private void ConfigureProgressionReset(LootLockerProgressionResetDetails progression)
{
Debug.Log(progression.name);
Debug.Log(progression.id);
Debug.Log(progression.key);
}
private void ConfigureGroup(LootLockerInlinedGroupDetails group)
{
Debug.Log(group.name);
Debug.Log(group.description);
foreach (var asset in group.assetDetails)
{
ConfigureAsset(asset);
}
foreach (var currency in group.currencyDetails)
{
ConfigureCurrency(currency);
}
foreach (var progression in group.progressionPointDetails)
{
ConfigureProgressionPoints(progression);
}
foreach (var progression in group.progressionResetDetails)
{
ConfigureProgressionReset(progression);
}
}

Conclusion

You've retrieved a list of Catalog items and converted it into an inline list you can use to display everything available for purchase. Learn more about Catalogs, or read up on Currencies, Wallets, and Real Money Purchases.