Skip to main content
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) into fixed slots, open/close the shelf with a controller button, and optionally sync state through VRInventorySubsystem.

Inspector setup

FieldPurpose
Player headForward/height reference for panel placement.
Right / left hand interactorNearFarInteractor — grab events; both wired to store-on-release over inventory.
Inventory model prefabShell mesh (rim feedback optional via _RimColor).
Inventory slot prefabMust include VRInventoryItem.
Toggle inventory actionInputActionReference — enables/disables in Start / OnDestroy.
Inventory distance / heightOffset in front of head (horizontal forward) and Y lift.
Max inventory itemsSlot count; drives circular layout.
Persist inventory statePassed 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):
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 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)

MemberDescription
isInventoryActiveWhether the panel is in “open” state (toggled).
IsInventoryVisualReadyTrue after open animation completes.
interactorExposes 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 firingRuntimeManager.InjectDependencies runs if EventDispatcher is not injected on this instance.

Unity Editor

VRInventoryManager component + inventory canvas.

VRInventoryManager in Unity Inspector or inventory UI