MolcaSDK.VR.InventoryFile:
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
UseVRInventoryManager when trainees should stash grabbed objects (e.g. after 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. |
Code
Clear every slot and destroy stored objects (dispatchesEventConstants.VR.ItemCleared per item):
EventConstants.VR.ItemStored, ItemRetrieved, InventoryOpened, InventoryClosed, etc., via EventDispatcher 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. |
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
VRInventoryItemto slot prefab. - Persistence not restoring — Requires
VRInventorySubsystemon RuntimeManager;persistInventoryStatemust be true and subsystem must register this manager. - Events not firing —
RuntimeManager.InjectDependenciesruns ifEventDispatcheris not injected on this instance.
Related
- Grab step — items users carry into inventory
- RuntimeManager —
VRInventorySubsystemregistration - EventDispatcher — inventory events
Unity Editor
VRInventoryManager component + inventory canvas.
