Forum begins after the advertisement:

The name ‘inventoryType’ does not exist in the current context

  • 31 August 2023: We recently fixed a bug where our Patrons were not getting their titles displayed properly on their posts.

Home Forums Video Game Tutorial Series Creating a Farming RPG in Unity The name ‘inventoryType’ does not exist in the current context

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #11791

    Help! I found a problem with my ‘inventoryType’ as my editor stating it does not exist. It was located in InventoryManager.cs and this is the code.

    if(inventoryType == InventorySlot.InventoryType.Item)
                //Iterate through each inventory slot and find an empty slot
                for(int i = 0; i < items.Length; i++)
                    if(items[i] == null)
                        //Send the equipped item over to its new slot
                        items[i] = equippedItem;
                        //Remove the item from the hand
                        equippedItem = null;

    And I already write it in InventorySlot.cs here:

    //Determines which inventory section this slot apar of
        public InventoryType inventoryType;

    Hi Ondra, you also need to declare the InventoryType enum before the variable, as the variable is using the InventoryType enum.

    Something like this:

    public enum InventoryType { Item, Tool }
    public InventoryType inventoryType;

    You have to check the video again to see what all the InventoryType enum options are. I might have forgotten some.


    Thanks. It’s already solved!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →

Advertisement below: