Unity inventory system script error C#

Updated on November 19, 2017 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on November 19, 2017

I’m currently making a game (in unity) and I’ve gotten stuck creating the script for part of the inventory (using visual studios). I’m fairly new to c# and I don’t understand what the error means, I’ve researched it and tried multiple fixes still haven’t gotten anywhere if someone could tell me how to resolve the error that would be appreciated. Many thanks.

The error is as follows:

Assets/Scripts/Inventory.cs(15,17): error CS0246: The type or namespace name `Item’ could not be found. Are you missing an assembly reference?

Here is the code:

using System.Collections;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using System.IO;

public class Inventory : MonoBehaviour
{
    GameObject inventoryPanel;
    GameObject slotPanel;
    public GameObject inventorySlot;
    public GameObject inventoryItem;

    int slotAmount;
    public List<Item> items = new List<Item>();
    public List<GameObject> slots = new List<GameObject>();

    void Start()
    {
        slotAmount = 32;
        inventoryPanel = GameObject.Find("Inventory panel");
        slotPanel = inventoryPanel.transform.Find("Slot Panel").gameObject;
        for (int i = 0; i < slotAmount; i++)
        {
            slots.Add(Instantiate(inventorySlot));
            slots[i].transform.SetParent(slotPanel.transform);
        }
    }
}
  • Liked by
Reply