- Home /
 
Error : Missing GUILayout.EndScrollView/EndVertical/EndHorizontal? UnityEditor.DockArea:OnGUI()
Im following the Adventure game tutorial to build an Inventory, in the tutorial they are only using 4 item slots, I need a few more than that. But when I try to add even one more slot I get the following errors when i try to click on the editor down arrow (on the far right) "for item slot 4":

All I have done is change the number of slots from 4 to 5:
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class Inventory : MonoBehaviour
 {
     public Image[] itemImages = new Image[numItemSlots];
     public Item[] items = new Item[numItemSlots];
     public const int numItemSlots = 5;
 
 
 
     public void AddItem(Item itemToAdd)
     {
        
         int id = itemToAdd.id;
         if (items.Length <= id)
             return;
         if (items [id]== null)
         {
             items[id] = itemToAdd;
             itemImages[id].sprite = itemToAdd.sprite;
             itemImages[id].enabled = true;
             return;
         }
 
 
        
     }
 
 
 
    public void RemoveItem(Item itemToRemove)
     {
         for (int i = 0; i < items.Length; i++)
         {
             if (items[i] == itemToRemove)
             {
                 items[i] = null;
                 itemImages[i].sprite = null;
                 itemImages[i].enabled = false;
                 return;
             }
         }
     }
 }
 
              Answer by mellovely · Mar 21, 2017 at 06:51 PM
In case anyone comes here with the same problem.
Adding these two lines in my Inventory Editor code worked for me and allowed me to add 26 numItemSlots! :)
 public override void OnInspectorGUI()
     {
         serializedObject.Update();
  
         itemImagesProperty.arraySize = Inventory.numItemSlots;
         itemsProperty.arraySize = Inventory.numItemSlots;
  
         for (int i= 0; i < Inventory.numItemSlots; i++)
         ...
 
              I used List<> ins$$anonymous$$d of arrays in the Inventory class and got the same error. Your answer fixed it!
THAN$$anonymous$$ YOU SO $$anonymous$$UCH!!! Geeeeez, this was driving me CRAZY.
Your answer
 
             Follow this Question
Related Questions
Instantiating object from inventory 0 Answers
GUISttyle NullReferenceException error. what am I missing ? 1 Answer
Inventory, why didn't work element? 1 Answer
NullReferenceException: Object reference not set to an instance of an object 1 Answer
How to make a simple inventory?!? Beginner coder JS 1 Answer