# Work with Loot Boxes In-Game

{% hint style="info" %}
This requires you to have set up a Loot Box in the management interface.

Please refer to the [guide on creating Loot Boxes](https://docs.lootlocker.com/content/working-with-assets/how-to/rarity-assets) for this
{% endhint %}

### Open Loot Box

After the player has either purchased or have been awarded a loot box they can open it.

This will remove the loot box from their inventory and grant them the item from the loot box.

To see what items were granted by the Loot box you can use the [Grant Notifications Method](https://docs.lootlocker.com/content/working-with-assets/how-to/check-grant-notifications)

{% tabs %}
{% tab title="Unity" %}

```csharp
int assetInstanceID = 90;
LootLockerSDKManager.OpenALootBoxForAssetInstances(assetInstanceID, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully opened Loot box");
    }
    else
    {
        Debug.Log("Error opening Loot box");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-0dd8b2f88f2e30ff2cd10010dd4f2e7c89a8c053%2Fimage.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/k6sivn6t/">Blueprint example of opening a lootbox</a></p></figcaption></figure>
{% endtab %}
{% endtabs %}

### Inspect Loot Box

Before opening a Loot Box we can inspect it to see what the player may get

{% tabs %}
{% tab title="Unity" %}

```csharp
int assetInstanceID = 90;
LootLockerSDKManager.InspectALootBoxForAssetInstances(assetInstanceID, (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully inspected Loot box");
    }
    else
    {
        Debug.Log("Error inspecting Loot box");
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-dcef127b2c92fa7d87905b6ba83d96dddc5c3988%2Fimage.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/0v1xo_2d/">Blueprint example of inspecting a lootbox</a></p></figcaption></figure>
{% endtab %}
{% endtabs %}
