This is a basic inventory system I made for my project, I had to extrapolate and refactor a few things to make it as general as possible and to remove the extra stuff I added for my game, so the code is not actually really polished and there may be some boilerplate code here and there because I didn't really review it entirely yet (sorry), but I think it's a good base for any inventory system you need and it's fairly easy to expand with new features and new item types. 

The system follows a Model-View-Controller pattern, with the model consisting of an InventorySO, which is a scriptable object (the actual inventory containing a list of ItemSOs), and the InventoryService, which manages its contents.

The view, on the other hand, consists of an UIInventoryPage that manages the UI and keeps it up to date.

And the controller is responsible for keeping the two parts in sync, handling requests made to the inventory.

Additionally, I’ve added the possibility to equip and unequip items (with an accompanying HUD).

If you want to use the model for additional views beyond the inventory, you can do it simply by adding a new View and a new controller that interacts with it. An example is the HUDController, which tracks equipped and unequipped items to display in the HUD.

If, on the other hand, you want to add other types of items besides consumables, you can do so simply by creating ScriptableObjects that inherit from ItemSO. The same applies to effects using new types of ItemActionSO.

If you have any feedback or find any bug let me know, I will try to update it soon with a more polished and better documented version.

Resources used:

Item sprites: https://knobiek.itch.io/items-16x16-free

EventHandler script: https://tinyurl.com/3yua96n4

Published 3 days ago
StatusIn development
CategoryTool
PlatformsHTML5
AuthorGioCriscuolo
Made withUnity
ContentNo generative AI was used

Download

Download NowName your own price

Click download now to get access to the following files:

InventorySystem.unitypackage 47 kB

Leave a comment

Log in with itch.io to leave a comment.