intermediate

Complete Inventory System

Drag-and-drop inventory with stackable items, equipment slots, and JSON save/load persistence.

5 scripts · 28 KB
RPGGeneral Any game with item management

Features

Drag & drop items between slots
Stackable items with max stack size
Equipment slots (head, chest, weapon, etc.)
ScriptableObject item definitions
JSON save/load persistence
Tooltip display on hover

Included Scripts

/inventory-system/
InventoryManager.cs
InventoryUI.cs
InventorySlot.cs
ItemData.cs
ItemDatabase.cs

Setup Guide

1

Import all scripts into your project

2

Create item ScriptableObjects using Create > Inventory > Item Data

3

Set up the ItemDatabase with your items

4

Create the inventory UI using the included prefab layout

5

Attach InventoryManager to your player

6

Connect the UI slots in the inspector

Code Preview

C#
// ItemData.cs - ScriptableObject for item definitions
[CreateAssetMenu(menuName = "Inventory/Item Data")]
public class ItemData : ScriptableObject
{
    public string itemName;
    public Sprite icon;
    public string description;
    public ItemType type;
    public int maxStack = 1;
    public bool isEquippable;
}

// InventoryManager.cs - Core inventory logic
public class InventoryManager : MonoBehaviour
{
    [SerializeField] private int slotCount = 20;
    private InventorySlot[] slots;

    public bool AddItem(ItemData item, int amount = 1) { /* ... */ }
    public bool RemoveItem(ItemData item, int amount = 1) { /* ... */ }
    public void SaveInventory(string path) { /* ... */ }
    public void LoadInventory(string path) { /* ... */ }
}

Available Individually

These scripts are also available as standalone downloads:

Related Systems