-
Notifications
You must be signed in to change notification settings - Fork 7
Inventory
The Inventory System is comprised of a system that works with Inventory Items. The basic inventory systems allow you to display an inventory in your game; additional Orders allow you to add/remove items, unlock/lock items and more.
Our 'Demo' prefab includes an Inventory object already to help you get started and is intended to be used alongside this page.
The Inventory sytem is ideal for allowing players to store Items which can be used in conjunction with Achievements, puzzles and Dialogues.
Within the demo prefab, you will find a more detailed Inventory prefab. This detailed prefab is essentially a scrollable list of Items that includes a detail panel disclosing information about the selected item. One can also find a simpler version of the Inventory as a prefab which includes just the scrollable list without the detail panel.

To use any Orders related to the Inventory, you must include an Inventory object in your scene - most Orders will require a reference to an inventory as the link is explicit rather than derived during runtime.
The Inventory prefab (s) contain child objects which are based on a UI canvas that help draw the Inventory to the screen. If you wish to modify the visuals of your Inventory then updating the canvas object is the most direct approach - just ensure you do not lose references that are required on specific class components used on the Inventory prefabs.
Most Items are derived from a simple Item base class. You can create new Inventory Items by navigating the Asset Creation menu to:
Create/LUTE/Inventory/Inventory/LUTE Inventory Item
You will also find other examples of extended Inventory Items within this context menu.
Once a new Item has been created you can fill out the relevant detail - ensure that the numerical ID is unique for each unique item!

An example of a basic Inventory Item defined as a scriptable object.
You can toggle the Inventory on and off with two Orders:
-
Inventory Button: this will create a button in the game that will toggle the Inventory on or off. - 'Toggle Inventory': this will just toggle the Inventory on or off when called (useful if you want to add an item and explicity show this has happened to the player).

The button that is created will either use the default sprite or one provided; players can then press this button and toggle the Inventory display. As stated above, feel free to modify the design of the Inventory but do ensure you references are not lost.
All Inventory Items are based on a base class which is comprised of basic information that is typical of an Item found within an Inventory (such as a name, icon, state and various sounds). You can extend this by inherting the parent class for custom use (for example, if you want custom behaviour to occur when the Item is "used").
In addition, an Item can be:
- Locked or Unlocked
- Consumed when used
- Stacked to a certain of infinite number (useful for Items such as coins)
You should ensure that every unique Item you create is given a unique ID number as this will help the system determine which Item is which.
You can add Items to your Inventory using the specific Order Add Item to Inventory

This will add the Item with the quantity provided to your Inventory. Consequently, you can Remove an Item using the Remove Item from Inventory Order.

Items that have been stacked (i.e., have more than 1) will reduce their amount by what has been specified. Items that are consumable will be removed from the Inventory if their quanitity reaches 0. You can ensure this does not occur by defining consumable as "false" on the Item itself.
Items can also be considered as collectibles. Oftentimes, players wish to know how many collectibles are left to be collected and seeing a locked Item incentivises players to find all the Items. You can achieve this by using the two Orders:
-
Unlock Inventory Itemand Lock Inventory Item

Items that are locked typically cannot be used and show a different icon. However, you can force locked Items to still be usable (say if you want to give a hint!) so that actions are different for the "Use" behaviour depending on the locked state of an Item.
A random Item can also be unlocked using either:
-
Unlock Random Itemor -
Unlock Random Item ButtonOrder.
This will go through the Inventory and choose a random locked Item to unlock - useful if Players start to get impatient...
As the Inventory system and Items rely rather heavily on scriptable objects, it can be tricky to reference objects in your scene. To help remove this pain we created the LUTE Inventory Item Mono Refclass. This handy class derives itself from Monobehaviour and can therefore sit in your scene on an object. The class will listen out for Inventory events (such as an Item being used or Moved) and act accordingly.
For example:
- Create an object in your scene and attach the class
- Define which Item you want the class to listen to
- Add a Unity Action event to the list and when the item is used this event will also be triggered
- Go further - expand the class and add more methods or behaviours to be triggered when that Item is used!
The idea behind this class is to help designers bridge the gap between scriptable objects and objects within their scenes as you cannot reliably reference scene objects from scriptable objects.

Extending upon the Monobehaviour references, we have created a simple mini-game example. In this case, if an Item is locked then we show a simple hint panel to help guide players to where the character is currently residing. If the Item is unlocked then we show a character panel with extended text and occasionally a button which will trigger some form of mini game (or simply call a method on another object).
To allow for this function to work as intended:
- Ensure there is a related
Character LUTE Inventory Itemscriptable object. - Ensure there is an object in your scene with the
Custom LUTE Inventory Item Mono Refclass component. - Define that Item outlined in step 1 that this object will relate to.
- Setup what action the button will trigger on the Character panel and then what character to display on the same panel.
The object will now listen for the Item events and:
- If locked, show the hint panel with the provided text defined in the Item scriptable object.
- If unlocked, display the character panel with details provided on both the scriptable object and the monobehaviour referenced object.

An example of the 'Character Panel' that is created when the custom Item is 'Used'.

An example of the custom character Inventory Item

An example of how the monobehaviour item should be setup - the mini game example here simply logs a message to the console but can be a lot more complex than this!