Granting Assets
In this section, after creating the asset definition, we will learn how to grant the actual holding of assets to the player and inspect it from the client side.
Before proceeding, make sure you've already gone through the Getting Started and Installation Guide guides. The code snippets here assume that you've created and are using a test user.
The player's holdings are represented by the AssetHolding
object. Both in the API and in the SDK you'll find two ways of fetching the holdings:
- as a connection - i.e. fetch them all in a paginated manner
- by an id - fetch concrete asset holding.
Structurally, AssetHolding consists of the following information:
- quantity - The total quantity of this asset held by the player.
- instances - If the asset is held as
unique
(refer touniqueProperties
of the AssetDefinition), this connection will hold allAssetInstance
objects, which are concrete instances of that Asset. - assetDefinition - References the
AssetDefinition
for this holding.
How to grant an asset holding
Players can acquire assets in several ways. The most typical method is through marketplaces, which we'll explore in more detail later in this guide. Alternatively, assets can be directly assigned to players via the Subroutine Dashboard. This feature is particularly useful for testing, debugging, or handling customer support issues.
Section about granting assets is coming soon.
Fetching Asset Holdings
Fetching asset holdings is a common operation used primarily to display a player's inventory. It allows you to access detailed information about a player's assets, such as the asset type, quantity, and other specific properties. Having granted the assets, you can now use this operation to retrieve the assets and present them on the client side.
You can fetch asset holdings directly via the SDK or GraphQL API. Here are examples of how to achieve this in Unity and GraphQL:
- Unity
- GraphQL
Client.Player.GetInventory(new PlayerAPI.GetInventoryProps
{}, (response) =>
{
Debug.Log(response.Holdings);
});
query AssetHolding($assetId: AssetRef!) {
player {
assetHolding(assetId: $assetId) {
quantity
instances(first: 50) {
edges {
node {
id
}
}
}
}
}
}