{"id":29406332,"url":"https://github.com/pietras333/inventory-system","last_synced_at":"2025-07-10T23:20:00.114Z","repository":{"id":303087035,"uuid":"1014365121","full_name":"pietras333/inventory-system","owner":"pietras333","description":"A robust, SOLID-principle-based inventory system for Unity games featuring drag-and-drop functionality, item stacking, splitting, and merging capabilities.","archived":false,"fork":false,"pushed_at":"2025-07-05T15:38:43.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-05T16:37:38.574Z","etag":null,"topics":["csharp","gamedev","inventory-system","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pietras333.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-05T15:22:28.000Z","updated_at":"2025-07-05T15:38:46.000Z","dependencies_parsed_at":"2025-07-05T16:53:20.395Z","dependency_job_id":null,"html_url":"https://github.com/pietras333/inventory-system","commit_stats":null,"previous_names":["pietras333/inventory-system"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pietras333/inventory-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pietras333%2Finventory-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pietras333%2Finventory-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pietras333%2Finventory-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pietras333%2Finventory-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pietras333","download_url":"https://codeload.github.com/pietras333/inventory-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pietras333%2Finventory-system/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264686782,"owners_count":23649565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","gamedev","inventory-system","unity3d"],"created_at":"2025-07-10T23:19:59.414Z","updated_at":"2025-07-10T23:20:00.098Z","avatar_url":"https://github.com/pietras333.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎮 Unity Inventory System\n\nA robust, SOLID-principle-based inventory system for Unity games featuring drag-and-drop functionality, item stacking, splitting, and merging capabilities.\n\n## ✨ Features\n\n- 🖱️ **Drag \u0026 Drop Interface** - Intuitive mouse-based item management\n- 📦 **Item Stacking** - Automatic stacking of identical items up to max stack size\n- ✂️ **Item Splitting** - Right-click to split item stacks in half\n- 🔄 **Item Merging** - Combine compatible items automatically\n- 🔁 **Item Swapping** - Swap items between slots seamlessly\n- 💡 **Tooltip System** - Hover tooltips with item information\n- 🏗️ **SOLID Architecture** - Clean, maintainable, and extensible code structure\n- 🔧 **ScriptableObject Configuration** - Easy customization without code changes\n- 🌐 **Network Ready** - Built with Unity Netcode integration in mind\n\n## 🛠️ Dependencies\n\nhttps://github.com/user-attachments/assets/dfa65463-711f-4976-9297-323d5d0a7070\n\n### Unity Version\n- **Unity 2022.3 LTS** or higher\n\n### Required Packages\n```json\n{\n  \"com.unity.textmeshpro\": \"3.0.6\",\n  \"com.unity.netcode.gameobjects\": \"1.7.1\" \n}\n```\n\n### Installation via Package Manager\n1. Open Unity Package Manager (`Window \u003e Package Manager`)\n2. Install **TextMeshPro** from Unity Registry\n3. Install **Netcode for GameObjects** from Unity Registry\n\n## 📁 Project Structure\n\n```\nAssets/\n├── 📂 Scripts/\n│   ├── 📂 Core/\n│   │   ├── 🔧 ItemDefinition.cs\n│   │   ├── 🔧 ItemContainerConfig.cs\n│   │   └── 🔧 ItemContainerSlotUIConfig.cs\n│   ├── 📂 Inventory/\n│   │   ├── 📦 ItemContainer.cs\n│   │   ├── 🎯 ItemContainerItemUI.cs\n│   │   └── 🎪 ItemContainerSlotUI.cs\n│   ├── 📂 DragSystem/\n│   │   ├── 🎮 ItemDragManager.cs\n│   │   ├── 🎯 InventoryInputHandler.cs\n│   │   ├── 🔧 ItemDragService.cs\n│   │   ├── ⚙️ ItemOperationService.cs\n│   │   └── 🎨 DragVisualizer.cs\n│   └── 📂 UI/\n│       └── 💬 TooltipUI.cs\n├── 📂 Prefabs/\n│   ├── 📦 InventoryContainer.prefab\n│   ├── 🎪 InventorySlot.prefab\n│   └── 🎮 ItemDragManager.prefab\n└── 📂 ScriptableObjects/\n    ├── 📂 Items/\n    │   ├── ⚔️ Sword.asset\n    │   ├── 🛡️ Shield.asset\n    │   └── 🧪 Potion.asset\n    └── 📂 Configs/\n        ├── 🔧 DefaultContainerConfig.asset\n        └── 🎨 DefaultSlotConfig.asset\n```\n\n## 🚀 Quick Start\n\n### 1. Setup Item Definitions\n```csharp\n// Create items via: Assets \u003e Create \u003e Inventory System \u003e Item\n// Configure: ID, Name, Description, Icon, Max Stack Size, Prefab\n```\n\n### 2. Create Inventory Container\n```csharp\n// 1. Create empty GameObject\n// 2. Add ItemContainer component\n// 3. Assign ItemContainerConfig\n// 4. Add ItemContainerSlotUI components as children\n// 5. Assign slots to the Slots list in ItemContainer\n```\n\n### 3. Setup Drag Manager\n```csharp\n// 1. Create ItemDragManager prefab in scene\n// 2. Assign DragVisualizer component\n// 3. Configure drag visual elements (Image, Text)\n```\n\n### 4. Configure UI Elements\n```csharp\n// Each slot needs:\n// - ItemContainerSlotUI component\n// - UI Image for slot background\n// - UI Image for held item display\n// - TextMeshProUGUI for amount display\n```\n\n## 🎯 Usage Examples\n\n### Adding Items to Inventory\n```csharp\npublic class InventoryManager : MonoBehaviour\n{\n    [SerializeField] private ItemContainer playerInventory;\n    [SerializeField] private ItemDefinition swordItem;\n    \n    void Start()\n    {\n        // Add 5 swords to inventory\n        playerInventory.TryAddItem(swordItem, 5);\n    }\n}\n```\n\n### Custom Item Operations\n```csharp\npublic class CustomItemOperations : MonoBehaviour, IItemOperationService\n{\n    public bool TryMoveItem(ItemContainerItemUI item, ItemContainerSlotUI targetSlot)\n    {\n        // Add custom logic (e.g., equipment restrictions)\n        if (item.ItemDefinition.ItemType == ItemType.Weapon \u0026\u0026 targetSlot.SlotType != SlotType.WeaponSlot)\n            return false;\n            \n        return defaultOperationService.TryMoveItem(item, targetSlot);\n    }\n    \n    // Implement other interface methods...\n}\n```\n\n## 🎨 Customization\n\n### Item Configuration\nCreate new items through the ScriptableObject menu:\n- **Right-click in Project** → **Create** → **Inventory System** → **Item**\n\n### Visual Customization\n- **Slot Icons**: Configure active/passive slot sprites in `ItemContainerSlotUIConfig`\n- **Drag Visuals**: Customize drag appearance in `DragVisualizer` component\n- **Tooltips**: Modify `TooltipUI` for custom tooltip styles\n\n### Extending Functionality\n```csharp\n// Add new item operations\npublic class EnchantmentService : IItemOperationService\n{\n    public bool TryEnchantItem(ItemContainerItemUI item, EnchantmentType enchantment)\n    {\n        // Custom enchantment logic\n        return true;\n    }\n}\n```\n\n## 🏗️ Architecture Overview\n\n### SOLID Principles Implementation\n\n- **🔧 Single Responsibility**: Each class has one clear purpose\n- **📖 Open/Closed**: Easy to extend without modifying existing code\n- **🔄 Liskov Substitution**: Interfaces can be swapped seamlessly\n- **🎯 Interface Segregation**: Focused, specific interfaces\n- **🔗 Dependency Inversion**: Depends on abstractions, not concrete classes\n\n### Key Components\n\n| Component | Responsibility |\n|-----------|---------------|\n| `ItemDragService` | 🎯 Manages drag state |\n| `ItemOperationService` | ⚙️ Handles item operations |\n| `DragVisualizer` | 🎨 Visual drag representation |\n| `InventoryInputHandler` | 🎮 Input processing |\n| `ItemDragManager` | 🎪 Facade coordinator |\n\n## 🧪 Testing\n\n### Unit Testing Setup\n```csharp\n[Test]\npublic void TestItemMerging()\n{\n    // Arrange\n    var mockDragService = new Mock\u003cIItemDragService\u003e();\n    var operationService = new ItemOperationService();\n    \n    // Act \u0026 Assert\n    Assert.IsTrue(operationService.TryMergeItems(item1, slot));\n}\n```\n\n## 🤝 Contributing\n\n1. 🍴 Fork the repository\n2. 🌟 Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. 💾 Commit changes (`git commit -m 'Add amazing feature'`)\n4. 📤 Push to branch (`git push origin feature/amazing-feature`)\n5. 🔄 Open a Pull Request\n\n## 📋 Requirements\n\n- ✅ Unity 2022.3 LTS+\n- ✅ TextMeshPro\n- ✅ Unity Netcode for GameObjects (optional)\n- ✅ C# 9.0+ support\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- 🎮 Unity Technologies for the excellent game engine\n- 👥 Game development community for inspiration and best practices\n- 📚 Clean Code principles by Robert C. Martin\n\n## 📞 Support\n\n- 🐛 **Bug Reports**: Open an issue with detailed reproduction steps\n- 💡 **Feature Requests**: Open an issue with [FEATURE REQUEST] prefix\n- 💬 **Questions**: Use GitHub Discussions for general questions\n\n---\n\n⭐ **Star this repository if you find it helpful!** ⭐\n\nMade with ❤️ for the Unity community\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpietras333%2Finventory-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpietras333%2Finventory-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpietras333%2Finventory-system/lists"}