Scene & Class Setup
v4.0
Last updated
v4.0
Last updated
To make use of the Drag-and-Drop Inventory System, some setup is required. Refer to the Party Based RPG demo game for reference.
The module uses a layer for displaying UI inventory. Create one called UIInventory.
The prefab Canvas 1920x1080
is a UI Canvas which you may find helpful to start with. This is the canvas used in the demo scene.
The "Demo Objects" and "Player Portraits" (highlighted in red below) are likely able to be removed for your project. Be sure to use the demo scene first to better understand what these sections do, as you may be able to make use of them for your project.
Check the "Inventory Module" object and it's children in the world scene of the Party Based RPG demo game to see these objects in context.
The objects turned off, Inventory Panel, Box Inventory Panel, and Small Box Inventory Panel, are useful if you'd like to create your own inventory panel prefabs using these as starting points. They are used in the demo scene, but can be utilized in your own projects, modified or unmodified. Be sure to create your own original prefabs from these objects.
This light is used to illuminate the UI inventory objects. While this is not required, we suggest you set up your inventory system before modifying the lighting.
If it makes sense for your scene, try modifying this based on the lighting in the location where the player is, so that inventory is darker in darker locations, and bright during the daylight.
This is the parent transform for the item being held by the OnScreenItem
script. This is required, though you could technically replace it with another parent if you have a reason to.
Bring the prefab Inventory Module Required Scripts
into your scene. Alternatively, you can add the scripts OnScreenItem
and PanelManager
into your scene. These scripts are required for the Inventory system to work.
OnScreenItem This script handles inventory objects when they are "held" by the player but not in a specific inventory. See the section on this script for more details.
Remember to populate the "Required" references in the inspector.
PanelManager
This script manages the various UI panels for visual inventories. Note that the playerInventoryPanel
is meant to always be in the scene, while panels that populate otherPanel
will be instantiated and destroyed at runtime -- these are panels which represent the inventories of other objects like treasure boxes, or enemies. See the section on this script for more details.
Remember to populate the "Required" references in the inspector.
IHaveInventory
Any class that has an inventory should implement IHaveInventory
.
If your custom Actor
class inherits from GameModulesInventoryActor
, then you already have most of what you need set up for your player inventory!
Anything can have an Inventory. Logically, things like enemies, NPCs, shops, treasure boxes, and of course players will have inventories. However, you can utilize the inventories on other objects as well, such as the surface of a bed or table, or a pedestal in a dungeon, where a user has to place a specific quest item to trigger some in game event.
Creative use of the Inventory module can expand the value of the module, and easily create game logic that you would have to otherwise code yourself.