# Box Setup (Chests, Bags, Other Inventories)

The **Inventory** module assumes a "Player Inventory", which is always available, and an "Other Inventory", which is variable for any other object which contains an inventory. Examples would include boxes, chests, drawers, or anything else that has an inventory attached to it.

![](https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FWGsa1TJNvPGAv1qqtE3v%2FScreenshot%202023-06-29%20at%209.25.53%20PM.png?alt=media\&token=41cb93d1-1f7e-4935-9571-6affd55d1878)

Check out the "Inventory Area" objects in the Party Based RPG demo game to see how we've set up a number of re-usable objects with different settings. You can use these, or copy them to make your own.

You can add your own UI, background, and other elements to make it "your own".

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2F8DkhJ1hjga0jXUksPkw7%2FScreenshot%202023-06-29%20at%209.28.05%20PM.png?alt=media&#x26;token=8673089f-8c68-48a9-a3d0-8f11daaa9b12" alt=""><figcaption><p>The highlighted area will be centered and scaled at runtime</p></figcaption></figure>

## Scripting setup

Each object which has an inventory should contain some script that you create which references the `Box Inventory Panel` prefab you copied and customized in the steps above. In the example below, we will populate the `public GameObject boxInventoryPrefab` with this object.

*Note that this script will need to be custom coded for your project, but you can utilize the examples here.*

![](https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MY3N_li2jPq7az6mYfq%2F-M_sSAoVPRieAE_oIzY2%2F-M_sVZVCdl4u46NhcL2R%2FScreen%20Shot%202021-05-16%20at%209.06.32%20PM.png?alt=media\&token=4383ae2a-148d-4d0a-860d-e5264a4f271d)

Your script should reference the PanelManager, which should be attached to an object in your scene. Here is one way to access it, at the top of the script.

```csharp
using static InfinityPBR.Modules.Inventory.PanelManager;
```

{% hint style="info" %}
[See the section on the `Panel Manager` for more scripting examples.](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/panelmanager)
{% endhint %}

In this code below, we will instantiate the panel, populate the `spots` and `items`, and display it.

```csharp
public void OpenInventory()
{
    panelManager.SetOtherPanel(panelManager.CreatePanel(boxInventoryPrefab, items, spots));
    if (!panelManager.otherPanel)
        return;

    panelManager.panelParent.gameObject.SetActive(true);
    panelManager.SetupOtherPanel();
}
```

&#x20;`PanelManager` will handle the rest for you.

{% hint style="success" %}
`BoxManager` already has this set up for you. I suggest you consider using it, or stealing from it!
{% endhint %}
