Would Drag/Drop System Support Mobile Touch Screen Drag/Drop?

Hi,

it is not clear yet in the " RPG Inventory Systems: Intermediate Unity C# Coding" course if the drag/drop system would be supported in Android application with touchscreen drag/drop (no mouse involved).
As I understood so far, they are developing a system where a mouse is clicking, dragging and dropping.

Can you please tell me if eventually the inventory system can be adapted to my android game? Or if it will require massive adjustment to implement the touchscreen?

Thank

Alex

I just did a test importing the drag and drop system on my game and it works when I test it on the PC using the mouse.

When I build the game in the mobile phone and I try to test the inventory again: I can drag the items around the mobile screen by touching and dragging them but I can’t swap the items in two slots.

I think the issue is when using PointerEventData.position defined in the library DragItems.
Am I missing interfaces for the touchscreen?

        void IEndDragHandler.OnEndDrag(PointerEventData eventData)
        {
            transform.position = startPosition;
            GetComponent<CanvasGroup>().blocksRaycasts = true;
            transform.SetParent(originalParent, true);

            IDragDestination<T> container;
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                container = parentCanvas.GetComponent<IDragDestination<T>>();
            }
            else
            {
                container = GetContainer(eventData);
                Debug.Log("Code is here");
            }

            if (container != null)
            {
                DropItemIntoContainer(container);
            }

            
        }

Alex

I think we may have discussed this in the Udemy section.
Unfortunately, the system has not been tested on mobile platforms, only mac and PC, as the RPG course is ultimately targetted at a PC environment.
As far as I understand it, the IDragHandlers are supposed to be platform agnostic, so I’m actually surprised it doesn’t work out of the box. More research is needed on this.

Indeed I haven’t tested this. But would be interest to see if anybody can get it to work. I see no reason it shouldn’t be possible as Brian said.

This topic was automatically closed after 14 days. New replies are no longer allowed.

Privacy & Terms