> ## Documentation Index
> Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
> Use this file to discover all available pages before exploring further.

# VRInventoryManager

> In-VR item storage and retrieval.

**Namespace:** `MolcaSDK.VR.Inventory`\
**File:** `Assets/_MolcaSDK/_VR/Scripts/Inventory/VRInventoryManager.cs`

World-space inventory ring that follows the **player head**, toggles via **Input System** action, and stores **`XRGrabInteractable`** items dropped near the UI. Registers with **`VRInventorySubsystem`** when present for optional **persistence**.

## When to use

Use **`VRInventoryManager`** when trainees should **stash grabbed objects** (e.g. after [Grab step](/vr/steps/grab-step)) into fixed slots, open/close the shelf with a controller button, and optionally **sync state** through **`VRInventorySubsystem`**.

## Inspector setup

| Field                            | Purpose                                                                           |
| -------------------------------- | --------------------------------------------------------------------------------- |
| **Player head**                  | Forward/height reference for panel placement.                                     |
| **Right / left hand interactor** | `NearFarInteractor` — grab events; both wired to store-on-release over inventory. |
| **Inventory model prefab**       | Shell mesh (rim feedback optional via **`_RimColor`**).                           |
| **Inventory slot prefab**        | Must include **`VRInventoryItem`**.                                               |
| **Toggle inventory action**      | `InputActionReference` — enables/disables in `Start` / `OnDestroy`.               |
| **Inventory distance / height**  | Offset in front of head (horizontal forward) and Y lift.                          |
| **Max inventory items**          | Slot count; drives circular layout.                                               |
| **Persist inventory state**      | Passed to **`VRInventorySubsystem.RegisterInventoryManager`**.                    |

If **toggle action** is missing, you get a **warning** and cannot open via input.

## Code

**Clear every slot and destroy stored objects** (dispatches **`EventConstants.VR.ItemCleared`** per item):

```csharp theme={null}
using MolcaSDK.VR.Inventory;

public class ResetInventory : MonoBehaviour
{
    [SerializeField] private VRInventoryManager inventory;

    public void ClearAll() => inventory.ClearAllSlots();
}
```

React to **`EventConstants.VR.ItemStored`**, **`ItemRetrieved`**, **`InventoryOpened`**, **`InventoryClosed`**, etc., via [EventDispatcher](/core/event-dispatcher) if other systems (scoring, steps) need hooks.

**`IsInventoryVisualReady`** becomes true only after the **open** animation finishes — use it before ray/UI tests that assume the panel is fully visible.

## API (key members)

| Member                       | Description                                                     |
| ---------------------------- | --------------------------------------------------------------- |
| **`isInventoryActive`**      | Whether the panel is in “open” state (toggled).                 |
| **`IsInventoryVisualReady`** | True after open animation completes.                            |
| **`interactor`**             | Exposes **`rightHandInteractor`** as **`IXRSelectInteractor`**. |
| **`ClearAllSlots()`**        | Empties slots, destroys items, fires clear events.              |
| **`GetInventorySlots()`**    | All **`VRInventoryItem`** slots.                                |
| **`GetAvailableSlot()`**     | First empty slot, or null.                                      |

Internal storage uses **`StoreItemInInventory`** when releasing a grab over the model.

## Troubleshooting

* **Cannot open inventory** — Assign **toggle inventory action** and ensure the action map is enabled for the active control scheme.
* **Items never store** — Release must happen while hovering the inventory (within about **0.2** world units of the model per source); increase proximity or adjust prefab scale/position. You also need a free slot.
* **"Inventory Slot Prefab must have VRInventoryItem"** — Add **`VRInventoryItem`** to slot prefab.
* **Persistence not restoring** — Requires **`VRInventorySubsystem`** on RuntimeManager; **`persistInventoryState`** must be true and subsystem must register this manager.
* **Events not firing** — `RuntimeManager.InjectDependencies` runs if **`EventDispatcher`** is not injected on this instance.

## Related

* [Grab step](/vr/steps/grab-step) — items users carry into inventory
* [RuntimeManager](/core/runtime-manager) — **`VRInventorySubsystem`** registration
* [EventDispatcher](/core/event-dispatcher) — inventory events

## Unity Editor

<Frame hint="VRInventoryManager component + inventory canvas." caption="VR inventory setup">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/vr-inventory-manager.png" alt="VRInventoryManager in Unity Inspector or inventory UI" />
</Frame>
