Setup

There're basically two ways of implementing the runtime UI. The easiest would be to simply drag the InventorySystem prefab into your scene and use the InventoryUIController singleton class to build the inventory appropriately. Please have a look at the InventoryDemo.cs script in the demo scene to see how this works. You can find the prefab here: Databrain.Add-ons / Inventory / Runtime / Prefabs The other way would be to build your inventory from scratch based on the InventorySystem prefab.

If you want to change the design of the UI please make sure to create a copy of all prefabs located in: Databrain.Add-ons / Inventory / Runtime / Prefabs

The runtime UI system is built upon several components. The following image shows you a very basic inventory UI setup:

InventoryUIController.cs

This is the main UI controller script which handles the main UI inventory logic. Can be assigned to an empty GameObject in the scene. Use it to build an inventory (populate items) at runtime. The InventoryUIController is a singleton. So you can use it like this: InventoryUIController.Instance.BuildInventory(data, uiRoot);

InventoryUIRootComponent.cs

This component must be assigned to the root UI image object of the inventory. This component must also be passed to the BuildInventory method of the InventoryUIController when building an inventory.

InventoryGridComponent.cs

This component must be assigned to an UI image object which is located inside of the root UI image. It is also recommended to add a UnityEngine UI GridLayout Group component to make sure items are aligned in a grid.

InventoryDescriptionComponent.cs (optional)

This component can be assigned to another UI image object to display an item description when hovering over an item.

Demo

The demo scene is a nice example of how this setup works based on those components. The demo scene makes use of all available runtime components.

Please see the Inventory demo scene to see how each of those components are used.

Last updated