Basic Setup Instructions
Last updated
Last updated
Setup for the Malbers Inventory Add-On is very simple.
Once imported, you will find various folders:
In order to use the inventory system, you will need to do the following:
JSON.Net
Animal Controller
If you haven't already, download Animal Controller/HAP FIRST, then download the Inventory Add-On after.
If you haven't already got it installed, you will also need to install JSON.net. If you receive errors like the following then you need to do that:
It should install by default, but if not, go into your package manager, then press the Plus icon in the top left and choose: Add Package by Name.
The name you want to give is: "com.unity.nuget.newtonsoft-json".
It will then install JSON.Net:
Once everything is installed, you should now see it underneath your Malbers Animations -> Integrations folder.
In the prefabs folder, you will find various prefabs. There will be one called InventoryCanvas. Drag this into your scene. The Inventory Canvas is a standard canvas that uses Screen-Space Overlay.
By default, all of the child objects will be set to inactive as per the screenshot below (we will sort that shortly!):
This prefab sets up a standard 4 x 4 grid for your inventories using 16 slots. Each slot that is added will automatically be generated an ID number at runtime. It's important to NOT edit these ID numbers. If you want a larger inventory, just add more Slot prefabs and the system will automatically find them and give them an ID.
As children of the InventoryUI gameobject, you will find all of your slots. Each slot should have an Inventory Slot script attached, as well as a Grid Layout Group:
The grid layout group is what handles snapping the item back into place when you remove it from a slot but don't assign it a new slot. Do not remove it.
You should also find an InfoPanel gameobject, as well as a InventoryTabsArea gameobject and a OtherButtons gameobject.
The InfoPanel is what is shown to the player when you hover over an item - like a tooltip.
The OtherButtons is the panel where all of your functional buttons are such as: Equip, Use, Unequip etc.
The InventoryTabsArea are where the individual Inventory Tabs are, and underneath them are your individual inventories.
Set up the General Tab as shown in the screenshot where the Steve Animal is your own that you are using with the Inventory system via using a TransformVar. For now, leave notifications and save system encryption turned off as we'll cover those later.
On the Buttons Tab, the buttons use TransformVar's and Hooks to populate the buttons - These should already be set up correctly but if not, add in the TransformVar's here:
You can see the hooks on the Inventory Gameobject here:
In the References Tab, we will need to add some references here too, but again, these should already be set for you:
These TransformVar's have hooks which link up to each individual Gameobject in the world.
You must put the Inventory TransformVar's in order that they are displayed e.g. If you have 5 tabs left to right, and it go's: General, Weapons, Armour, Resouces, KeyItems - then you must register the inventories in that order for the tab switching to correctly work.
For Registered Items, we will leave this blank for now as we will be creating our first item in this section: Creating a new Item
In order for buffs/debuffs to work correctly and effect all the unarmed damagers, you need to add the attack triggers into the List of Damager Components on the References Tab. This way, they have a reference to all the unarmed damagers when applying certain all damage buffs etc.
Next, on the Inventories, on the tabs, you need to set up those references:
You don't need to set the Inventory Master as that is set at runtime automatically.
You need to give the Inventory a unique Inventory Name and set the Inventory Type to "Player". You can set a dropping offset as well if you wish but feel free to leave it to the default which drops it 2 units in front and above you. Inventory Slots you will not need to touch as this gets generated at runtime automatically.
On the functional buttons e.g. Equip, Use etc. You need to set up references back to your Inventory master. This will allow a cyclic connection. You do this via setting the "Player" TransformVar as shown here:
If you are amending one of the Malbers demo scenes, you will need to remove the existing On Item Picked event for Holster_SetWeapon as shown in this screenshot. This is because setting the holsters will be handled directly via the Inventory and not directly when you pick up the item anymore.
You may also want to consider the InventoryUI Gameobject and make sure all the references are set there as well. These should be set by default as they are all internal within the prefab itself, but if not, set them up as per screenshot.
Also consider the children of the HeaderButtons gameobject.
Each child corresponds to the image of the tab at the top of the inventory. Each one should have an Event Trigger component as a Pointer Down as per screenshot:
Again, this should be set by default in the prefab, but if not, then order your Tabs 1 to 5. E.g. General is the first tab, so it is Tab 1.
To open/close the inventory (or any screen in the Inventory Add-On), you will need the UIManager Prefab added into your scene from the InventorySystem -> Prefabs folder.
Then once you've done that, simply add a new input on your Malbers Input component of type "Down" e.g. Button press type, then add this:
The Event Listener for this exists on the UIManager Prefab and then it triggers the UIManager.SwitchUIState. This is called whenever a new screen is opened/closed.
If you are setting up the inventory on the back of one of the Malbers AC demo scenes, there is a settings menu included that disables the cursor. Obviously you will need the cursor when using the inventory. Therefore, make sure you also do this when setting your input:
You can also consider things like disabling camera input/movement here as well, but I shall leave this up to the user to decide what is best for their game.
And that's it! That's the basic setup complete. Next step is to start creating your own items so you can collect them and use them - see the next page for more information!