• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by mellovely · Mar 20, 2017 at 04:31 PM · guierrorinventory

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":

alt text

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;
             }
         }
     }
 }
error.png (415.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4

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++)
         ...

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image johnburkert · Jun 26, 2017 at 04:31 PM 0
Share

I used List<> ins$$anonymous$$d of arrays in the Inventory class and got the same error. Your answer fixed it!

avatar image kenji255 · Sep 30, 2017 at 06:03 PM 0
Share

THAN$$anonymous$$ YOU SO $$anonymous$$UCH!!! Geeeeez, this was driving me CRAZY.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Instantiating object from inventory 0 Answers

GUI not working correctly? (Double tooltip display)(c#) 1 Answer

Sudden GUI.DrawTexture errors 1 Answer

Pick up gameobject and go to inventory, 1 Answer

Error: Optimized GUI Block text buffer 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges