Subnautica Inventory UI (VR)

What is it?

I’ve noticed that many of the best UIs have multiple different workflows to accomplish the same thing - this one’s no exception. As a fun technical challenge, I decided to try replicating the Subnautica inventory UI in Unity, making it work on both Windows and Quest 2 (VR). It’s proven to be quite interesting and a bit more complicated than I expected… details below!

How I did it.

This system has three main parts:

  • Data Model - The goal of the data model is to store items as efficiently as possible in a grid, and to determine whether a given item can be added. This is an instance of the NP-Hard Bin Packing Problem. To solve it, I’ve implemented a Maximal Rectangles algorithm that sorts the items by height and then places them into the highest open space.

  • UI Layout - With the data model in place, this part was easy - simply map the grid coordinates to screen space coordinates to place items in the correct location at the correct size. The fun part was when I brought everything to life by easing each item into position, so whenever the layout is changed, all the items slide around to their new location.

  • User Interaction - This UI has several different workflows to transfer items between inventories: single click, click and drag, and swapping. Making sure these all work together smoothly and have matching visual states was a neat challenge, particularly since I’m targeting VR platforms that typically have two pointers. Here’s a feature list for User Interaction:

    • Hover - tooltip with item name & description; yellow border highlight

    • Click and Release - transfers item to the other container

    • Click and Drag - item loosely follows the active pointer. Two items can be dragged around at the same time in VR using the two controllers.

      • Drop over another container - if the target container has space, transfers the item to it.

      • Drag over an item in another container - if swapping is possible, locks the dragged item’s position and displays the Swap Tooltip.

      • Drop over an item in another container - if swapping is possible, swaps the dragged item and the targeted item.

I think the hardest part of this little project was supporting 2 VR controllers without issues. Even though I designed the system for it from the start, I ran into several surprising bugs when using both controllers at the same time. As a user, I can’t imagine myself wanting to use both at the same time, but I think it ought to be possible in a VR setting with two controllers, even if most users would likely use only one at a time.

Screenshots & Videos:

Links: