Forum rules - please read before posting.

Inventory Shift Right when Item Drag and Hover over Shift-Right-Button

ac.156b, u544p4

I have 10 inventory items and 6 slots with shift left and shift right buttons.
a tester wanted to combine item 1 with item 10.
and intuitively tried to drag item 1 on the shift right arrow and kept it there expecting it would slowly scroll to the end.

Is that possible?
I don't know what "Screen Arrows" are but this bug fix sounds like it's that ...
  • Fixed: Screen Arrows not responding to drag input on Touch Screen devices
the configuration " items can be reordered in menu" doesn't do anything  in ui i think.

I made a demo video in your demo2d


my config is ...
menu type : unity ui

config:
Input method: Touch Screen
Interaction method: Context Sensitive
[  ] Lock cursor ...
[  ] Hide cursor ...

Inventory Settings
[x] Combine interactions work in reverse?
[x] Drag and Drop Inventory interface?
 Minimum drag distance 0
[ ] can drop item onto itself
[ ] Auto disable hotspots with no interaction for sele ...
 Active cursor FX None
[x] show active fx when an interaction is unhandled?
[ ] items can be reordered in menu (this doesn't do anything in my case)

Touch Settings:
[   ] moving touch drags cursor
[   ] activate hotspots with double-tap
[   ] Release touch to interact with pause menus?

Comments

  • The "Screen arrows" mentions in the changelog refer to Arrow Prompts - you can ignore that.

    As you're doing this with Unity UI.  This can be done with a separate script.  I've written such a script in the wiki: http://adventure-creator.wikia.com/wiki/Shifting_inventory_with_drag-and-drop
  • Thank you, I got it working.
    In the demo 2d it worked right away.

  • Is there any way to get this working with an AC menu?

  • Yes and no. This should be possible by hooking into the OnMouseOverMenu custom event, but this is not currently called when dragging inventory items over menu elements that items can't be dropped onto.

    I shall correct this in the next release. Once this update is out, the following script should do it:

    using UnityEngine;
    using AC;
    
    public class DragDropInventoryButtonAC : MonoBehaviour
    {
    
        [SerializeField] private float totalHoldTime = 0.4f;
        [SerializeField] private string menuName = "Inventory";
        [SerializeField] private string shiftButtonName = "ShiftLeft";
    
        private bool isOver = false;
        private float currentHold;
    
        private void OnEnable ()
        {
            EventManager.OnMouseOverMenu += OnMouseOverMenuElement;
        }
    
        private void OnDisable ()
        {
            EventManager.OnMouseOverMenu -= OnMouseOverMenuElement;
        }
    
        private void OnMouseOverMenuElement (Menu menu, MenuElement element, int slot)
        {
            if (menu.title == menuName && element != null && element.title == shiftButtonName)
            {
                StartWait ();
            }
            else
            {
                isOver = false;
            }
        }
    
        private void Update ()
        {
            if (isOver)
            {
                if (KickStarter.playerInput.GetMouseState () != MouseState.HeldDown)
                {
                    isOver = false;
                }
    
                if (currentHold > 0f)
                {
                    currentHold -= Time.deltaTime;
    
                    if (currentHold <= 0f)
                    {
                        Menu menu = PlayerMenus.GetMenuWithName (menuName);
                        MenuButton shiftButton = menu.GetElementWithName (shiftButtonName) as MenuButton;
                        shiftButton.ProcessClick (menu, 0, MouseState.SingleClick);
                        StartWait ();
                    }
                }
            }
        }
    
        private void StartWait ()
        {
            isOver = true;
            currentHold = totalHoldTime;
        }
    
    }
    
  • Thanks Chris!

  • edited December 2023

    Nevermind, I figured it out! :)

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.