LootLocker
The BasicsGame SystemsContent ManagementPlayer Management
LootLocker
  • 📌The Basics
    • Getting Started
    • What is LootLocker?
    • Core Concepts
      • Players
      • Assets
      • Character Classes
      • API Types
      • Web Console
      • Stage & Live Environments
      • Glossary
    • Unity Quick Start
      • Install the SDK
      • Configure the SDK
      • Authenticate Your First Player
      • Update the SDK
    • Unreal Quick Start
      • Install & Configure the SDK
        • Older versions
      • Authenticate Your First Player
    • Godot Quick Start
      • Install the SDK
      • Configure the SDK
      • Authenticate Your First Player
      • Update the SDK
    • SDKs
    • Samples
      • Authentication Samples
      • Leaderboard Samples
      • Progression Samples
      • Player Samples
    • Launching Your Game
    • Support
      • Error Codes
      • Unreal Marketplace Plugin Support
  • 🎭Players
    • Overview
    • Authentication
      • How To
        • Guest Login
        • Steam
        • Apple
        • Apple Game Center
        • Google
        • Epic Games
        • PlayStation
        • Meta / Oculus
        • Xbox
        • Nintendo Switch
    • Files
      • How To
        • Manage Files in Web Console
        • Work with Files In-Game
    • Inventory
      • How To
        • Work with Player Inventory
    • Messages
      • How To
        • Configure Messages in Web Console
    • Names
      • How To
        • Work with Player Names
    • Player Manager
      • How To
        • Manage Players through Web Console
        • Manage Players In-Game
        • Use Player Operations
    • Unified Player Accounts
      • How To
        • Configure UPA in Web Console
        • Use Remote Login In-Game
        • Connect Identiy Provider to Player
        • External Provider Linking
        • Transition from Guest Login to Other Provider
        • Disconnect Identity Provider from Player
    • White Label Login
      • How To
        • Configure White Label Login
        • Create a New White Label User
        • Request User Verification
        • Handle Returning Users
        • Start a White Label Session
  • 🪙Commerce
    • Overview
    • Catalogs
      • How To
        • Configure Catalogs in LootLocker Console
        • List all Catalogs
        • Use Catalogs In-Game
        • Setup In-Game Store
    • Currencies
      • How To
        • Configure a Currency in Web Console
        • Use Currencies In-Game
    • DLC Management
      • How To
        • Configure DLC in Web Console
        • Use DLC In-Game
    • Entitlements
      • How To
        • Work with Entitlements In-Game
    • Real Money Purchases
      • How To
        • Configure In-App Purchase in Web Console
        • Make Purchases through Google Play Store
        • Make Purchases through Apple Store
        • Make Purchases through Steam Store
    • Virtual Purchases
    • Wallets
      • How To
        • Manage a Wallet in Web Console
        • Use Wallets In-Game
  • ⚔️Content
    • Overview
    • Assets
      • How To
        • Create & Configure an Asset
        • Organize & Search for Assets
        • Retrieve Assets In-Game
        • Set up Asset Storage Template
        • Check Grant Notifications
        • Set up a Game Config Asset
        • Create a Loot Box
        • Work with Loot Boxes In-Game
        • Create a Drop Table
        • Work with Drop Tables In-Game
        • Create a Rental Asset
        • Work with Rental Assets In-Game
    • User Generated Content (UGC)
      • How To
        • Create UGC In-Game
    • Twitch Drops
  • 🕹️Game Systems
    • Overview
    • Classes & Heroes
      • How To
        • Base Classes
        • Hero Classes
        • Implement Classes In-Game
        • Implement Heroes In-Game
    • Leaderboards
      • How To
        • Configure Leaderboard in Web Console
        • Use Player Leaderboards
        • Use Generic Leaderboards
        • Use Metadata to Store Additional Information
        • Use Scheduled Reset with Rewards
        • Use Leaderboards for Time Based Rankings
      • Leaderboard FAQ
      • GameMaker References
    • Feedback
      • How To
        • Manage Feedback Categories
        • Create Player Feedback
        • Create UGC Feedback
        • Create Game Feedback
        • View and Manage Feedback
    • Progressions
      • How To
        • Create a Progression
        • Game Progressions
        • Player Progressions
        • Class Progressions
        • Asset Instance Progressions
    • Triggers
      • How To
        • Setup a trigger in the Web Console
        • Invoke trigger from game
  • ⛓️Shared Systems
    • Overview
    • Metadata
      • How To
        • Add Metadata in Console
        • Fetch a Single Metadata In-Game
        • Fetch Metadata In-Game by Tags
        • Fetch Metadata In-Game from Multiple Sources
    • Notifications
      • How To
        • List Notifications and Mark as Read In-Game
  • 🗝️Admin
    • Settings
    • User Settings
    • Organization Settings
    • CORS Allowlist
  • ⭕️ Legacy
    • Deprecations
      • Unity SDK Deprecation Log
        • Version 2.1.5 - Migration to Open UPM
        • Version 2.0.0
      • Unreal SDK Deprecation Log
        • Version 4.0.0
        • Version 3.0.0
    • Legacy Storage
    • Legacy Triggers
      • Activate a trigger
      • Create a trigger
    • Legacy Progressions
      • Create a Progression System
      • Use a Progression System In-Game
Powered by GitBook
On this page
  • Prerequisites
  • Retrieve Asset
  • Retrieve Assets With Filter
  • Retrieve Assets by IDs
  • Retrieve Favourite Assets
  • Add Favorite Asset
  • Remove Favourite Asset
  • Working With Assets For Player in Game
  • Get All Key Value Pairs to an Instance
  • Get A Key Value Pair By Id
  • Create A Key Value Pair
  • Update One Or More Key Value Pairs
  • Delete Key Value Pair
  1. Content
  2. Assets
  3. How To

Retrieve Assets In-Game

PreviousOrganize & Search for AssetsNextSet up Asset Storage Template

Last updated 6 months ago

In this How-to we will demonstrate how to fetch an Asset from the backend to be displayed in your game.

Prerequisites

  • A LootLocker account

  • A created game in the web console

  • An active Asset

Retrieve Asset

To start retrieving assets you can run following:

int count = 10;
LootLockerSDKManager.GetAssetListWithCount(count, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved " + response.assets.Length + " assets");
    }
    else
    {
        Debug.Log("Error retrieving assets");
    }
});

After the initial method has completed retrieving assets you can call this method to get more:

LootLockerSDKManager.GetAssetNextList(count, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved second batch of " + response.assets.Length + " assets");
    }
    else
    {
        Debug.Log("Error retrieving assets");
    }
});

If you want to retrieve all you assets you can keep calling the method until you stop receiving assets.

After finishing retrieving the assets you need, it's best practice to run the following code, as if you try to get assets later, you might start from your previous last retrieved asset.

This is only relevant for Unity! This is not the case for Unreal.

LootLockerSDKManager.ResetAssetCalls();

Retrieve Assets With Filter

int count = 10;
List<LootLocker.LootLockerEnums.AssetFilter> filter = new List<LootLocker.LootLockerEnums.AssetFilter>() { LootLocker.LootLockerEnums.AssetFilter.nonpurchasable };

LootLockerSDKManager.GetAssetListWithCount(count, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved " + response.assets.Length + " assets");

    }
    else
    {
        Debug.Log("Error retrieving assets");
    }
}, filter);

To use Filters, simply specify the filter you want to retrieve assets with, through the same blueprint as before.

Retrieve Assets by IDs

If you already know the IDs of the assets you wish to get, you can use this method to retrieve them specifically.

string[] list = new string[] { "8111" };

LootLockerSDKManager.GetAssetsById(list, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved " + response.assets.Length + " assets");
        Debug.Log("First Asset ID: " + response.assets[0].id);

    }
    else
    {
        Debug.Log("Error retrieving assets");
    }
});

Retrieve Favourite Assets

LootLockerSDKManager.ListFavouriteAssets((response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved " + response.favourites.Length + " assets");

        if (response.favourites.Length > 0)
        {
            Debug.Log("First Asset ID: " + response.favourites[0]);
        } else
        {
            Debug.Log("No favourite assets");
        }
    }
    else
    {
        Debug.Log("Error retrieving assets");
    }
});

Add Favorite Asset

LootLockerSDKManager.AddFavouriteAsset("8111", (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully favourited asset");
    }
    else
    {
        Debug.Log("Error favouriting asset");
    }
});

Remove Favourite Asset

LootLockerSDKManager.RemoveFavouriteAsset("8111", (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully removed favourite asset");
    }
    else
    {
        Debug.Log("Error removing favourite asset");
    }
});

Working With Assets For Player in Game

Get All Key Value Pairs to an Instance

LootLockerSDKManager.GetAllKeyValuePairsToAnInstance(45781352, (response) =>
{
    if (response.success)
    {
        if (response.storage.Length > 0)
        {
            Debug.Log("Successfully retrieved " + response.storage.Length + " key value pairs");
        }
        else
        {
            Debug.Log("No key value pairs for asset instance");
        }
    }
    else
    {
        Debug.Log("Error retrieving assets");
    }
});

Get A Key Value Pair By Id

int assetInstanceID = 84;
int keyValueID = 1;
LootLockerSDKManager.GetAKeyValuePairByIdForAssetInstances(assetInstanceID, keyValueID, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved key value pair");
    }
    else
    {
        Debug.Log("Error retrieving key value pair");
    }
});

Create A Key Value Pair

LootLockerSDKManager.CreateKeyValuePairForAssetInstances(45781352, "some-new-key", "value here", (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully created key value pair for asset instance");
    }
    else
    {
        Debug.Log("Error creating key value pair");
    }
});

Update One Or More Key Value Pairs

int assetInstanceID = 84;

Dictionary<string, string> multipleTestKeys = new Dictionary<string, string>();

multipleTestKeys.Add("some-new-key", "Some value");
multipleTestKeys.Add("some-other-key", "Some other value");
LootLockerSDKManager.UpdateOneOrMoreKeyValuePairForAssetInstances(assetInstanceID, multipleTestKeys, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully updated key value pairs");
    }
    else
    {
        Debug.Log("Error updating key value pairs");
    }
});

Delete Key Value Pair

int assetInstanceID = 84;
int keyValuePairID = 1;

LootLockerSDKManager.DeleteKeyValuePairForAssetInstances(assetInstanceID, keyValuePairID, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully removed key value pair");
    }
    else
    {
        Debug.Log("Error removing key value pair");
    }
});
⚔️
Blueprint example of how to retrieve assets
Blueprint example of how to retrieve assets
Blueprint example of retrieving assets by ids
Blueprint example of retrieving favourite assets
Blueprint example of adding an asset to Favourites
Blueprint example of removing an asset from Favourites
Blueprint example of retrieving all key value pairs
Blueprint example of getting a specific key value pair
Blueprint example of creating a key value pair
Blueprint example of updating one or more pairs
Blueprint example of deleting a key value pair