Forum rules - please read before posting.

Combining two inventory items on different "pages"

Hi there!

I’m using drag n’ drop to let the player combine inventory items with one another. This works fine except for when the second item on a different “page” than the first item (by page I mean that a ShiftNext is required to see it).

I’m trying to make it so that when the player is drag n’ dropping an item, the ShiftNext button should be activated on mouse-enter rather than on mouse-click (which I use when not drag n’ dropping).

I have attached a behavior on the ShiftNext button:

public void OnPointerEnter(PointerEventData eventData)
{
    if (KickStarter.runtimeInventory.SelectedItem != null)
    {
        // Alt 1: No error but the inventory box isn't shifted visually
        inventoryBoxMenuElement.Shift(AC_ShiftInventory.ShiftNext, 4);

        // Alt 2: No error but the inventory box isn't shifted visually
        menu.Initalise();
        shiftDownMenuButton.ProcessClick(menu, 4, MouseState.SingleClick);

        // Alt 3: Works but also deselects the selected inventory item so
        // that it can no longer be combined with the new visiblie items
        KickStarter.playerInput.SimulateInputButton("ShiftInventoryNext");
    }
}

But as you can see from the comments, nothing has worked so far…

I understand that this can be tricky so I created a repro Unity package here:
https://1drv.ms/u/s!Amz_vh8OYDX3u6FJE6O0m2WqB184VQ

Instructions:
1. Drag n’ drop an item from the inventory over the ShiftNext button (the lower one of the two buttons on the left)
2. Note that the selected item is deselected (according to Alt 3)

I also tried to change the "Responds to" value for the ShiftNext button in runtime - but also no luck.
Any idea how to solve this?

Thanks!

Comments

  • Your script is manipulating the original Menu in the Menu Manager, not the runtime instance of it.

    menu = PlayerMenus.GetMenuWithName ("InventoryUI");
    

    See the Manual's "Menu scripting" chapter for more on how to access Menus through script.

  • Ah, that works great, thanks!

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.