Forum begins after the advertisement:


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

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
    Posts
  • #11791
    Ondra Dwi Putra Adi Setyo
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    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;
                        break;
                    }
                }
            }
    

    And I already write it in InventorySlot.cs here:

    //Determines which inventory section this slot apar of
        public InventoryType inventoryType;
    #11803
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    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.

    #11808
    Ondra Dwi Putra Adi Setyo
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    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: