CodeBlanks Logo Icon CodeBlanks

Project: Inventory design

Learn how to design an inventory system in this project.

Inventory System Design

An inventory system allows the player to store and manage collected objects in an organized way. Before implementation, decide which information will be stored and how objects will be added or removed. In a simple system, item name, quantity, and inventory capacity can be basic requirements.

Inventory
  Items
  Add Item
  Remove Item
  Display Items

Basic Inventory Responsibilities

An inventory system can have separate responsibilities. Storing item data, accepting a new item, removing an existing item, and displaying its contents are examples. Organizing these operations into separate methods improves code readability.

StoreItemData()
AddItem()
RemoveItem()
DisplayInventory()

Practice Create the Inventory Class Skeleton

Create a C# class named InventorySystem to represent the inventory system. Inside the class, define a public Initialize method that can be implemented later without performing any operation yet.

Starter code

Player.cs
using UnityEngine;

Sample solution

Player.cs
using UnityEngine;

public class InventorySystem : MonoBehaviour
{
    public void Initialize()
    {
    }
}

Expected output

Inventory sistemi hazır

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the most appropriate action before coding an inventory system?

  • Planning the data and basic operations to be stored Correct answer
  • Deleting every object from the scene
  • Locking the game's resolution
  • Creating a separate Unity scene for every item

Explanation: Planning determines which data the inventory stores and which operations it supports.

2 Purpose of Inventory Planning

Question
Envanter tasarımında öncelikle saklanacak veriler ve desteklenecek işlemler için bir ____ hazırlanır.
Answer
Envanter tasarımında öncelikle saklanacak veriler ve desteklenecek işlemler için bir plan hazırlanır.

Explanation: A plan helps define the system's requirements and responsibilities.

3 Match Inventory Requirements

Term Meaning
Eşya verisi The object's name and properties
Ekleme Including a new object in collection
Çıkarma Removing an object from collection
Görüntüleme Displaying stored objects info

All lessons in Intermediate