> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts.md).

# Scripts

v4.0

## Scripts

A variety of scripts are included with the Drag-and-Drop Inventory System, which help drive the logic and runtime operations. Some need to be utilized on in-game objects, and others added to various prefabs for your items. See the setup sections for more details.

These are in the `InfinityPBR.Modules.Inventory` namespace.

Please see the sections [`OnScreenItem`](/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/onscreenitem.md), [`PanelManager`](/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/panelmanager.md) and [`Panel`](/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/panel.md) for information on those scripts, which are required in your scene.

{% hint style="success" %}
The Prefab **Inventory Module Required Scripts** is required, and should be brought into your scene. It holds the `PanelManager` and `OnScreenItem` classes.

You will then need to populate the fields. Check the scripts detail pages for more.
{% endhint %}

## UI related scripts

### [**PanelManager**](#panelmanager)

This is the main management script for the Inventory system, and handles the active panels.

### [OnScreenItem](#onscreenitem)

This is the class which manages the item that is "held" on the screen. When held, it follows the mouse, as if the player is holding the item.

### [**Panel**](/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/panel.md)

This is the script which drives the in game UI panel of buttons on a grid, where UI inventory items will be shown. Please reference the prefabs to see how they are utilized in the demo scene.

### **GridButton**

This script is attached to the UI button prefabs (`Inventory Grid Button`) and handles player interaction with the button.

### **GridRow**

This script is used on the `Panel`, and holds a `List<GameObject>` of UI buttons (grid buttons). A `List<GridRow>` will hold all the buttons in the UI panel.

## Item Scripts

Please see the [Item Setup](/magic-pig-games/game-modules-4/game-module-systems/inventory/item-object-setup.md) section for details on how to set up your item prefabs for the Drag-and-Drop Inventory System.

{% hint style="success" %}
Each Item will have two objects, one for the inventory display, and one for the world display. They should be based on the same prefab/mesh, but will have slightly different setups.
{% endhint %}

### **ItemInventory**

This is added to the *Inventory* version of your items. The `GameObject` field `inGamePrefab` should be populated with the world version of the item.

### **ItemWorld**

This should be attached to the world version of your items. You do not need to populate the `ItemObject` data -- that will be populated automatically at run time.

Note, if you are instantiating items into the world outside of the Drag-and-Drop Inventory System, then you will need to populate the `ItemObject` data appropriately.

## **Box Manager**

This script controls our virtual treasure boxes. Check the "Small Treasure Box" and "Lucky Large Treasure Box" objects in the world scene of the Party Based RPG demo game.
