> 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/panelmanager.md).

# PanelManager

v4.0

The `PanelManager` class manages the inventory panels during runtime. This is needed for games where there are up to two inventory panels active at once -- the player inventory panel, and potentially a "Other panel", which could be a treasure box or other object that has an inventory. This way, the user can easily navigate between the player inventory panel, the other panel, and transfer items back and forth.

{% hint style="success" %}
This class is attached to the Prefab `Inventory Module Requires Scripts`. Bring that into your project.
{% endhint %}

{% hint style="info" %}
This is a static method, which you can utilize via this code at the top of your script:

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

{% endhint %}

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FMWoxhye6ZytIL3K9iObK%2FScreenshot%202023-06-29%20at%207.29.32%20PM.png?alt=media&amp;token=eff43c46-2a63-489e-a531-105b3c139e71" alt=""><figcaption><p>A populated <code>PanelManager</code> from the Party Based RPG demo game</p></figcaption></figure>

## Required fields

### **Player Inventory Panel** *(Optional)*

The module assumes that there will be an "always on" inventory panel for the player. While this is not static by any means, and can display the inventory of various players, such as in a game where there are multiple player members of a party, the inventory panel is assumed to not be destroyed or instantiated at run time.

While technically optional, we expect most projects will make use of this.

### **UI Camera** *\[Hidden in Inspector]*

This is the camera used to show the UI Inventory and canvas. This is set automatically by the `PanelManager` class.

### **Panel Parent**

Inventory panels instantiated will be parented under this `Rect Transform`.

### **Show Debug Messages**

When true, the Console will show `Debug.Log` messages during key events. This is helpful if you want to better understand which methods are being called during your interaction with the **Inventory** module. It will toggle off automatically when not in the Unity Editor.

## Public methods

### Get Active Panel

This will return whichever panel is active. It could be the player panel, or an "other" panel. Will return `null` if there is no active panel.

```csharp
public Panel ActivePanel
```

### Get Active Panel

This will return whichever panel is active. It could be the player panel, or an "other" panel. Will return `null` if there is no active panel.

```csharp
public Panel ActivePanel
```

### Set "Other" Panel

This will populate the `otherPanel` with the `newPanel` passed in, and optionally set the new panel to activate.

```csharp
public Panel SetOtherPanel(Panel newPanel, GameObject obj, bool setActive = true)
```

### Toggle Panels On/Off

Use these methods to set the Player panel and the Other panel active. The other will turn off at the same time.

`iHaveInventoryGameId` is the GameId of the object which will have its inventory displayed.

```csharp
public void ToggleOtherInventoryPanel(bool turnOn = true)
public void TogglePlayerInventoryPanel(bool turnOn = true
    , string iHaveInventoryGameId = "")
    
// Example from Party Based RPG demo game calss GameData.cs
// OpenPlayerInventory()...
panelManager.TogglePlayerInventoryPanel(true, ActivePlayer.GameId());
```
