Forum rules - please read before posting.

Question about Inventory slots used

Hello Chris,
Thanks for the replies.
We want to achieve a simple effect on our Inventory box (actually, it's a wallet). Whenever you hover over a slot, the piece of paper raised and gives you the description.

https://imgur.com/a/wWNdQGA

You can see how it works in those two pics.

Now, the questions are the following:
1) Is there a way to check how many displayed items are there at the moment? Because if I have only two items, I don't want to raise the right paper or even the third one on left side. Maybe check which slots are being used at the moment. Of course, the slots are 6 but if I have more elements, they will be on another page, so it's 6 in one screen and then the other 2.

2) I also noticed that the slot spacing doesn't allow to some "crazy" combinations such as group items by three (in this case), then add some space and add the other ones. I was thinking if there's a way to create two boxes but don't repeat elements which are currently displayed? Maybe I'm way off with this one... but asking won't hurt anyone. As of now, you can see in the picture that the space between items is always the same, but it's not exactly how we want it. Though it works!

Thanks a lot and have a nice day.

Comments

  • Is there a way to check how many displayed items are there at the moment?

    I understand the intent behind the left paper raising when hovering over an item, but I'm not clear on the right paper.

    To work out how many Inventory slots are filled in your InventoryBox menu element, however, you can loop through the class's GetItem function:

    public int GetNumSlotsFilled ()
    {
        int numSlotsFilled = 0;
        MenuInventoryBox inventoryBox = (MenuInventoryBox) PlayerMenus.GetElementWithName ("MyMenu", "MyInventoryBox");
        for (int i = 0; i < inventoryBox.GetNumSlots (); i++)
        {
            InvItem itemInSlot = inventoryBox.GetItem (i);
            if (itemInSlot != null)
            {
                numSlotsFilled ++;
            }
        }
        return numSlotsFilled;
    }
    

    As of now, you can see in the picture that the space between items is always the same, but it's not exactly how we want it.

    If your Menu is rendered using Unity UI, items are displayed in Button GameObjects that can be arranged to suit your need. When a Menu is linked to Unity UI, AC won't control the position of individual elements.

    A tutorial on working with Unity UI can be found here.

  • This worked great. With the help of some triggers I made it work like a charm. Thanks a lot Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.